ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-09-14 03:24:33
Exec Total Coverage
Lines: 9226 12216 75.5%
Functions: 384 441 87.1%
Branches: 7294 12923 56.4%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113385 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113385 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1113108 times.
1113385 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1113108 times.
1113108 if (c < 0)
56 c -= val / 2;
57 1113108 else c += (val/2);
58 1113108 }
59 1113385 c -= c % val;
60 1113385 coord = c;
61 1113385 }
62
63 38564049 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38047443 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38562834 times.
38564049 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38532514 times.
38562834 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38532514 times.
38532514 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38532448 times.
38532514 if (x > world_w+256) return true;
69 38532448 return false;
70 38564049 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 424 void identifyCFEnemies()
108 {
109 424 trapConstantHorizontalID=-1;
110 424 trapConstantVerticalID=-1;
111 424 trapLOSHorizontalID=-1;
112 424 trapLOSVerticalID=-1;
113 424 trapLOS4WayID=-1;
114 424 cornerTrapID=-1;
115 424 centerTrapID=-1;
116 424 rockID=-1;
117 424 zoraID=-1;
118 424 statueID=-1;
119
120
2/2
✓ Branch 0 taken 217088 times.
✓ Branch 1 taken 424 times.
217512 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 216669 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 419 times.
217088 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 419 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 216658 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 424 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 216664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 424 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 216664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 424 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 216664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 424 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 216664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 424 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 216664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 424 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 216664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 424 rockID=i;
140
4/4
✓ Branch 0 taken 447 times.
✓ Branch 1 taken 216641 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 421 times.
217088 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 421 zoraID=i;
142
143
4/4
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 216601 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 424 times.
217088 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 424 statueID=i;
145 217088 }
146 424 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806969 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600909 times.
✓ Branch 1 taken 206060 times.
806969 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit() const
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 2418535 bool enemy::shadow_overpit() const
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 30550936 times.
✓ Branch 1 taken 2405848 times.
32956784 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 12687 times.
✓ Branch 1 taken 30538249 times.
30550936 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 12687 return true;
271 }
272 30538249 }
273 }
274 2405848 return false;
275 2418535 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438667 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438667 times.
7438667 if(moveflags & move_ignore_blockflags) return false;
281 7438667 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895519 times.
✓ Branch 1 taken 2543148 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142761 times.
9981815 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524824 times.
✓ Branch 1 taken 4913843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524824 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438667 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584370 times.
✓ Branch 1 taken 4854297 times.
✓ Branch 2 taken 2582493 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582493 times.
✗ Branch 5 not taken.
14878098 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582493 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433745 times.
✓ Branch 5 taken 148748 times.
2582493 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577217 times.
✓ Branch 1 taken 2428469 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574547 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574300 times.
✓ Branch 3 taken 247 times.
2577217 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573482 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573416 times.
✓ Branch 3 taken 66 times.
2574300 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562790 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146537 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998463 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2573121 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2587011 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696119 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696119 times.
8696119 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597137 times.
✓ Branch 1 taken 2098982 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348778 times.
10795101 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611644 times.
✓ Branch 1 taken 2084475 times.
✓ Branch 2 taken 2084475 times.
✗ Branch 3 not taken.
10780594 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1202011 times.
✓ Branch 1 taken 7494108 times.
16190227 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483965 times.
✓ Branch 1 taken 10143 times.
7494108 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483846 times.
✓ Branch 1 taken 119 times.
7483965 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483675 times.
✓ Branch 1 taken 171 times.
7483846 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483420 times.
✓ Branch 1 taken 255 times.
7483675 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240891 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962836 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231302 times.
✓ Branch 1 taken 1248114 times.
7479416 (pit_blocks && ispitfall(dx,dy))));
309 8696119 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282052 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282052 int32_t c = COMBOTYPE(dx,dy);
314 282052 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246498 times.
282052 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282032 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281915 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281915 times.
✗ Branch 5 not taken.
1062905 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281915 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250042 times.
✓ Branch 5 taken 31873 times.
281915 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281342 times.
✓ Branch 1 taken 249469 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280955 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280924 times.
✓ Branch 3 taken 31 times.
281342 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277269 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276994 times.
✓ Branch 3 taken 275 times.
280924 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275950 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553949 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223787 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139611 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137288 times.
✓ Branch 1 taken 2323 times.
139611 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139611 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139611 times.
279222 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139514 times.
✓ Branch 1 taken 97 times.
139611 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139509 times.
✓ Branch 1 taken 5 times.
139514 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139500 times.
✓ Branch 1 taken 9 times.
139509 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139471 times.
✓ Branch 1 taken 29 times.
139500 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137150 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278692 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137150 times.
✓ Branch 1 taken 2071 times.
139221 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
230480 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115240 {
344
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 x=X;
345
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 y=Y;
346
3/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115240 id=Id;
348 115240 clk=Clk;
349
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 floor_y=y;
350 115240 ceiling=false;
351 115240 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115240 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115240 did_armos=true;
355 115240 script_spawned=false;
356
357 115240 d = guysbuf + (id & 0xFFF);
358 115240 hp = d->hp;
359 115240 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115240 flags=d->flags;
364 115240 flags=d->flags;
365 115240 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115240 type=d->type;
367 115240 dcset=d->cset;
368 115240 cs=dcset;
369
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115240 dp=d->dp;
371 115240 wdp=d->wdp;
372 115240 wpn=d->weapon;
373 115240 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115240 rate=d->rate;
375 115240 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dstep=d->step;
377 115240 homing=d->homing;
378 115240 dmisc1=d->attributes[0];
379 115240 dmisc2=d->attributes[1];
380 115240 dmisc3=d->attributes[2];
381 115240 dmisc4=d->attributes[3];
382 115240 dmisc5=d->attributes[4];
383 115240 dmisc6=d->attributes[5];
384 115240 dmisc7=d->attributes[6];
385 115240 dmisc8=d->attributes[7];
386 115240 dmisc9=d->attributes[8];
387 115240 dmisc10=d->attributes[9];
388 115240 dmisc11=d->attributes[10];
389 115240 dmisc12=d->attributes[11];
390 115240 dmisc13=d->attributes[12];
391 115240 dmisc14=d->attributes[13];
392 115240 dmisc15=d->attributes[14];
393 115240 dmisc16=d->attributes[15];
394 115240 dmisc17=d->attributes[16];
395 115240 dmisc18=d->attributes[17];
396 115240 dmisc19=d->attributes[18];
397 115240 dmisc20=d->attributes[19];
398 115240 dmisc21=d->attributes[20];
399 115240 dmisc22=d->attributes[21];
400 115240 dmisc23=d->attributes[22];
401 115240 dmisc24=d->attributes[23];
402 115240 dmisc25=d->attributes[24];
403 115240 dmisc26=d->attributes[25];
404 115240 dmisc27=d->attributes[26];
405 115240 dmisc28=d->attributes[27];
406 115240 dmisc29=d->attributes[28];
407 115240 dmisc30=d->attributes[29];
408 115240 dmisc31=d->attributes[30];
409 115240 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 110965 times.
115240 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110965 dmisc31 = dmisc32;
413 110965 dmisc32 = 0;
414 110965 }
415 115240 spr_shadow=d->spr_shadow;
416 115240 spr_death=d->spr_death;
417 115240 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724840 times.
✓ Branch 1 taken 115240 times.
4840080 for(int32_t i=0; i<edefLAST255; i++)
420 4724840 defense[i]=d->defense[i];
421
422 115240 bgsfx=d->bgsfx;
423 115240 hitsfx=d->hitsfx;
424 115240 deadsfx=d->deadsfx;
425 115240 bosspal=d->bosspal;
426
427 115240 frozentile = d->frozentile;
428
429 115240 frozencset = d->frozencset;
430 115240 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1152400 times.
✓ Branch 1 taken 115240 times.
1267640 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1959080 times.
✓ Branch 1 taken 115240 times.
2074320 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115240 isCore = true; //t.b.a
436 115240 parentCore = 0; //t.b.a
437
438 115240 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115240 script = d->script;
443
444
2/2
✓ Branch 0 taken 921920 times.
✓ Branch 1 taken 115240 times.
1037160 for ( int32_t q = 0; q < 8; q++ )
445 {
446 921920 initD[q] = d->initD[q];
447 921920 }
448
449 115240 stickclk = 0;
450 115240 submerged = false;
451 115240 didScriptThisFrame = false;
452 115240 activated_handle = std::nullopt;
453 115240 hitdir = -1;
454 115240 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8921 times.
✓ Branch 1 taken 106319 times.
115240 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8921 times.
✗ Branch 1 not taken.
8921 loadpalset(csBOSS,pSprite(bosspal));
462 8921 }
463
464
2/2
✓ Branch 0 taken 50331 times.
✓ Branch 1 taken 64909 times.
115240 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50331 times.
✗ Branch 1 not taken.
50331 cont_sfx(bgsfx);
467 50331 }
468
469
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 if(get_qr(qr_NEWENEMYTILES))
470 {
471 89096 o_tile=d->e_tile;
472 89096 frate = d->e_frate;
473 89096 }
474 else
475 {
476 26144 o_tile=d->tile;
477 26144 frate = d->frate;
478 }
479
480 115240 tile=0; //init to 0 here, but set it later.
481
482 115240 scripttile = -1;
483 115240 scriptflip = -1;
484 115240 do_animation = true;
485 115240 immortal = false;
486 115240 noSlide = false;
487 115240 deathexstate = -1;
488
489 115240 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109447 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115240 if(o_tile==0 && type!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102943 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115240 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102943 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102244 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102943 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
115240 step = zslongToFix(dstep*100);
501
502
503 115240 item_set = d->item_set;
504 115240 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 90351 times.
✓ Branch 1 taken 24889 times.
115240 if(frate == 0)
507 24889 frate = 256;
508
509 115240 leader = itemguy = dying = scored = false;
510 115240 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 115240 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114874 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115240 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 7242 times.
115240 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 115240 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✓ Branch 3 taken 97534 times.
115240 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_waterdrown;
548 17706 }
549
550 115240 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 115240 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 weap_data = d->weap_data;
554 115240 }
555
556 114983 enemy::~enemy()
557 114983 {
558
1/2
✓ Branch 0 taken 114983 times.
✗ Branch 1 not taken.
114983 FFCore.destroySprite(this);
559
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114970 times.
114983 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
562 13 hashero=false;
563 13 }
564 114983 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
3/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 1038 times.
✗ Branch 3 not taken.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 38011691 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 38009324 times.
✓ Branch 1 taken 2367 times.
38011691 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 38011680 return false;
1022 38011691 }
1023
1024 // Handle drowning in water
1025 38009324 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 38009324 times.
✗ Branch 1 not taken.
38009324 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 38009324 return false;
1063 38009324 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38674710 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38672881 times.
38674710 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 765577 times.
✓ Branch 1 taken 37907304 times.
38672881 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765577 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 765577 --clk2;
1083
1084
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 39920 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
765577 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1086 38736 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 722043 times.
✓ Branch 1 taken 43534 times.
765577 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42830 times.
✓ Branch 1 taken 704 times.
43534 if(flags&guy_never_return)
1091 704 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43463 times.
✓ Branch 1 taken 71 times.
43534 if(leader)
1094 71 kill_em_all();
1095
1096 43534 leave_item();
1097 43534 }
1098
1099 765577 stop_bgsfx(index);
1100 765577 return (clk2==0);
1101 }
1102
1103 37907304 return false;
1104 38674710 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 38011947 bool enemy::animate(int32_t index)
1110 {
1111 38011947 update_current_screen();
1112
2/2
✓ Branch 0 taken 1723938 times.
✓ Branch 1 taken 36288009 times.
38011947 if(sclk <= 0) hitdir = -1;
1113
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 38011691 times.
38011947 if(switch_hooked)
1114 {
1115
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1116 {
1117 //Run its script
1118 if (!didScriptThisFrame)
1119 {
1120 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1121 {
1122 return 0; //Avoid NULLPO if this object deleted itself
1123 }
1124 }
1125 }
1126 256 return false;
1127 }
1128
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 38011680 times.
38011691 if(do_falling(index)) return true;
1129
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 38009324 times.
38011680 else if(fallclk)
1130 {
1131 //clks
1132
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1133 704 --hclk;
1134
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1135 --stunclk;
1136
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1137 --frozenclock;
1138
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1139 {
1140 Hero.setX(x);
1141 Hero.setY(y);
1142 Hero.fallCombo = fallCombo;
1143 Hero.fallclk = fallclk;
1144
1145 if(hashero)
1146 {
1147 hashero = false; //Let Hero go if falling
1148 Hero.setEaten(0);
1149 }
1150 }
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1152 {
1153 2356 run_script(MODE_NORMAL);
1154 2356 }
1155 2356 return false;
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if(do_drowning(index)) return true;
1158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 else if(drownclk)
1159 {
1160 //clks
1161 if(hclk>0)
1162 --hclk;
1163 if(stunclk>0)
1164 --stunclk;
1165 if ( frozenclock > 0 )
1166 --frozenclock;
1167 if(hashero)
1168 {
1169 Hero.setX(x);
1170 Hero.setY(y);
1171 Hero.drownclk = drownclk;
1172
1173 if(hashero)
1174 {
1175 hashero = false; //Let Hero go if falling
1176 Hero.setEaten(0);
1177 }
1178 }
1179 if (!didScriptThisFrame)
1180 {
1181 run_script(MODE_NORMAL);
1182 }
1183 return false;
1184 }
1185 38009324 int32_t nx = real_x(x);
1186 38009324 int32_t ny = real_y(y);
1187
1188
4/4
✓ Branch 0 taken 27480339 times.
✓ Branch 1 taken 10528985 times.
✓ Branch 2 taken 5660595 times.
✓ Branch 3 taken 21819744 times.
38009324 if(ox!=nx || oy!=ny)
1189 {
1190 16189580 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1191 16189580 }
1192
1193 38009324 ox = nx;
1194 38009324 oy = ny;
1195
1196 // Maybe they fell off the bottom in sideview, or were moved by a script.
1197
1198 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1199
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38007495 times.
38009324 if ( immortal )
1200 {
1201 //skip, as it can go out of bounds, from immortality
1202 1829 }
1203
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38007495 times.
✓ Branch 2 taken 38007495 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38007495 times.
38007495 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1204 {
1205 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1206 }
1207
2/2
✓ Branch 0 taken 37975894 times.
✓ Branch 1 taken 31601 times.
38007495 else if (OUTOFBOUNDS(id, x, y))
1208 {
1209 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1210 31601 }
1211 //fall down
1212 38009324 handle_termv();
1213
6/6
✓ Branch 0 taken 27192563 times.
✓ Branch 1 taken 10816761 times.
✓ Branch 2 taken 10546498 times.
✓ Branch 3 taken 27462826 times.
✓ Branch 4 taken 511441 times.
✓ Branch 5 taken 10035057 times.
38009324 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9647359 times.
10035057 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1220 {
1221 157378 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 157378 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 157378 y+=fall/100;
1242
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= get_terminalv_fall())
1243 139566 fall += get_grav_fall();
1244 }
1245 157378 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 277 do_fix(y, 8); //Fix position
1252 277 }
1253
1254 230320 fall = 0;
1255 }
1256 387698 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= get_terminalv_fall())
1287 fall += get_grav_fall();
1288 }
1289 }
1290 387698 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_fake_z))
1294 {
1295
2/2
✓ Branch 0 taken 5079296 times.
✓ Branch 1 taken 4568063 times.
9647359 if(fakefall!=0)
1296 4568063 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5079296 times.
9647359 if(fakez<0)
1299 4568063 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5079296 times.
5079296 else if(fakefall <= get_terminalv_fall())
1301 5079296 fakefall += get_grav_fall();
1302
1303
5/6
✓ Branch 0 taken 9647359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5079296 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 496986 times.
9647359 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 9647359 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_real_z))
1306 {
1307
2/2
✓ Branch 0 taken 5512182 times.
✓ Branch 1 taken 4135177 times.
9647359 if(fall!=0)
1308 4135177 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5526754 times.
9647359 if(z<0)
1311 4120605 z = fall = 0;
1312
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5516697 times.
5526754 else if(fall <= get_terminalv_fall())
1313 5516697 fall += get_grav_fall();
1314
1315
6/6
✓ Branch 0 taken 9605145 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5484540 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 493851 times.
9647359 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 9647359 }
1317
1318 }
1319 10035057 }
1320 38009324 handle_termv();
1321
9/10
✓ Branch 0 taken 29780223 times.
✓ Branch 1 taken 8229101 times.
✓ Branch 2 taken 28485223 times.
✓ Branch 3 taken 1295000 times.
✓ Branch 4 taken 28485223 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4179477 times.
✓ Branch 7 taken 25600746 times.
✓ Branch 8 taken 18452882 times.
✓ Branch 9 taken 22632359 times.
38009324 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1322 {
1323
4/4
✓ Branch 0 taken 22216835 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13056224 times.
✓ Branch 3 taken 9160611 times.
22632359 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1324 9160611 fallCombo = check_pits();
1325
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 22216835 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 22074937 times.
22632359 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1326 141898 drownCombo = check_water();
1327 22632359 }
1328
1329 74915088 runKnockback(); //scripted knockback handling
1330
1331 // clk is incremented here
1332
2/2
✓ Branch 0 taken 72604719 times.
✓ Branch 1 taken 2310369 times.
74915088 if(++clk >= frate)
1333 2310369 clk=0;
1334
1335 // hit and death handling
1336
2/2
✓ Branch 0 taken 1255709 times.
✓ Branch 1 taken 73659379 times.
74915088 if(hclk>0)
1337 1255709 --hclk;
1338
1339
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 74238843 times.
74915088 if(stunclk>0)
1340 676245 --stunclk;
1341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74915088 times.
74915088 if ( frozenclock > 0 )
1342 --frozenclock;
1343
1344
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 74900212 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
74915088 if(ceiling && z <= 0 && fakez <= 0)
1345 124 ceiling = false;
1346
1347 74915088 try_death();
1348
1349 74915088 scored=false;
1350
1351 74915088 ++c_clk;
1352
1353 //Run its script
1354
2/2
✓ Branch 0 taken 36930581 times.
✓ Branch 1 taken 37984507 times.
74915088 if (!didScriptThisFrame)
1355 {
1356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37984507 times.
37984507 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1357 {
1358 return 0; //Avoid NULLPO if this object deleted itself
1359 }
1360 37984507 }
1361
1362 // returns true when enemy is defeated
1363 74915088 return Dead(index);
1364 74917711 }
1365
1366 38761623 bool enemy::setSolid(bool set)
1367 {
1368
1/2
✓ Branch 0 taken 38761623 times.
✗ Branch 1 not taken.
38761623 bool actual = set && !isSubmerged();
1369 38761623 bool ret = solid_object::setSolid(actual);
1370 38761623 solid = set;
1371 38761623 return ret;
1372 }
1373 void enemy::doContactDamage(int32_t hdir)
1374 {
1375 Hero.hithero(guys.find(this), hdir);
1376 }
1377
1378 22405 void enemy::solid_push(solid_object *obj)
1379 {
1380
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1382 22405 zfix dx, dy;
1383 22405 int32_t hdir = -1;
1384 22405 solid_push_int(obj,dx,dy,hdir,true);
1385
1386
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1387
1388 263 bool t = obj->getTempNonsolid();
1389 263 obj->setTempNonsolid(true);
1390
1391 263 int32_t ydir = dy > 0 ? down : up;
1392 263 int32_t xdir = dx > 0 ? right : left;
1393
1394 263 auto special = isflier(id) ? spw_floater : spw_none;
1395
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1396 {
1397 //Crushed?
1398 7 }
1399
1400 263 obj->setTempNonsolid(t);
1401 22405 }
1402 22405 bool enemy::is_unpushable() const
1403 {
1404 22405 return isSubmerged();
1405 }
1406 22087 bool enemy::sideview_mode() const
1407 {
1408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1409 }
1410
1411 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1412 {
1413 3234 int32_t yg = (special==spw_floater)?8:0;
1414 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1415
1416
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1417 4732 return true;
1418
1419 3238 bool isInDungeon = isdungeon(screen_spawned);
1420
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1421 {
1422
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1423 1199 return true;
1424
1425
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1426
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1427 return true;
1428 595 }
1429
1430
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1431 {
1432
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1433
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1434 return true;
1435 62 }
1436
1437
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1438 {
1439 case spw_clipbottomright:
1440 if(dy>=128 || dx>=208) return true;
1441 break;
1442 case spw_clipright:
1443 break; //if(x>=208) return true; break;
1444
1445 case spw_wizzrobe: // fall through
1446 case spw_floater: // Special case for fliers and wizzrobes - hack!
1447 {
1448
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1449 {
1450
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1451
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1452 595 }
1453 857 return false;
1454 }
1455 }
1456
1457 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1458 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1459
1460 if(special==spw_water)
1461 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1462
1463 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1464 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1465 870 }
1466
1467 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1468 {
1469 6575 bool kb = false;
1470 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1471
1472
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1473 return true;
1474
1475
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1476 {
1477
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1478 return true;
1479
1480
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1481 return true;
1482 1513 }
1483
1484
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1485 {
1486
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1487
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1488 return true;
1489 6575 }
1490
1491
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1492 {
1493
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1495 }
1496 else
1497 {
1498
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1499
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1502 }
1503 6575 }
1504
1505 // returns true if cannot walk
1506 32505729 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1507 {
1508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505729 times.
32505729 if(moveflags & move_new_movement)
1509 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1510 32505729 int32_t yg = (special==spw_floater)?8:0;
1511 32505729 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1512
2/2
✓ Branch 0 taken 3724406 times.
✓ Branch 1 taken 28781323 times.
32505729 switch(dir)
1513 {
1514 case l_down:
1515 case r_down:
1516 case down:
1517 case 11: //r_down
1518 case 12: //down
1519 case 13: //l_down
1520 {
1521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724406 times.
3724406 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1522 {
1523
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724406 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1524 {
1525 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1526
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1527 8 }
1528 3724406 }
1529 3724406 break;
1530 }
1531 }
1532
2/2
✓ Branch 0 taken 3726357 times.
✓ Branch 1 taken 28779372 times.
32505729 switch(dir)
1533 {
1534 case r_up:
1535 case r_down:
1536 case right:
1537 case 9: //r_up
1538 case 10: //right
1539 case 11: //r_down
1540 {
1541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726357 times.
3726357 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1542 {
1543
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726357 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1544 {
1545 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1546
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1547 3 }
1548 3726357 }
1549 3726357 break;
1550 }
1551 }
1552
1553
10/10
✓ Branch 0 taken 22401875 times.
✓ Branch 1 taken 10103854 times.
✓ Branch 2 taken 8754457 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066678 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043475 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454867 times.
✓ Branch 9 taken 32498342 times.
32505729 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1554 44917121 return true;
1555
1556 32498342 bool isInDungeon = isdungeon(screen_spawned);
1557
4/4
✓ Branch 0 taken 3976583 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964827 times.
32498342 if(isInDungeon || special==spw_wizzrobe)
1558 {
1559
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1560 11487907 return true;
1561
1562
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1563
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1564 113905 return true;
1565 5785039 }
1566
1567
6/6
✓ Branch 0 taken 3102356 times.
✓ Branch 1 taken 6647510 times.
✓ Branch 2 taken 750728 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699498 times.
9749866 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1568 {
1569
4/4
✓ Branch 0 taken 3044709 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043757 times.
6094933 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1570
4/4
✓ Branch 0 taken 3044526 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043807 times.
✓ Branch 3 taken 719 times.
3044709 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1571 7369 return true;
1572 3043757 }
1573
1574
4/4
✓ Branch 0 taken 7555697 times.
✓ Branch 1 taken 2180546 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742497 switch(special)
1575 {
1576 case spw_clipbottomright:
1577
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1578 707 break;
1579 case spw_clipright:
1580 5281 break; //if(input_x>=208) return true; break;
1581
1582 case spw_wizzrobe: // fall through
1583 case spw_floater: // Special case for fliers and wizzrobes - hack!
1584 {
1585
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641679 times.
7555697 if(isInDungeon)
1586 {
1587
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1588
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1589 4639539 }
1590 7553557 return false;
1591 }
1592 }
1593
1594 2186534 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1595
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699945 times.
2186534 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1596
1597
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771857 times.
2186534 if(special==spw_water)
1598
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1599
1600
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 59949 times.
1771857 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1601 {
1602
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1603
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1604 }
1605 else
1606 {
1607
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 17040 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102594 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1608
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1610
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1611 }
1612 10129559 }
1613
1614 496901 bool enemy::isOnSideviewPlatform()
1615 {
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1619 return false;
1620
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1622
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1623 {
1624
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1625
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1627 64328 }
1628 215641 return false;
1629 496901 }
1630
1631 // Stops playing the given sound only if there are no enemies left to play it
1632 768489 void enemy::stop_bgsfx(int32_t index)
1633 {
1634
2/2
✓ Branch 0 taken 753379 times.
✓ Branch 1 taken 15110 times.
768489 if(bgsfx<=0)
1635 753379 return;
1636
1637 // Look for other enemies with the same bgsfx
1638
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1639 {
1640
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1641 6304 return;
1642 46690 }
1643
1644 8806 stop_sfx(bgsfx);
1645 768489 }
1646
1647
1648 // to allow for different sfx on defeating enemy
1649 40356 void enemy::death_sfx()
1650 {
1651
2/2
✓ Branch 0 taken 40071 times.
✓ Branch 1 taken 285 times.
40356 if(deadsfx > 0) sfx(deadsfx,pan(x));
1652 40356 }
1653
1654 void enemy::move(zfix dx,zfix dy)
1655 {
1656 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1657 {
1658 x+=dx;
1659 y+=dy;
1660 }
1661 }
1662
1663 18374579 void enemy::move(zfix s)
1664 {
1665
9/10
✓ Branch 0 taken 18374540 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18265431 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18374579 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1666 {
1667 18373535 sprite::move(s);
1668 18373535 }
1669 18374579 }
1670
1671 43836 void enemy::leave_item()
1672 {
1673 43836 int32_t drop_item = select_dropitem(item_set, x, y);
1674 43836 int32_t thedropset = item_set;
1675
1676 43836 std::vector<int32_t> &ev = FFCore.eventData;
1677 43836 ev.clear();
1678 43836 ev.push_back(getUID());
1679 43836 ev.push_back(drop_item*10000);
1680 43836 ev.push_back(thedropset*10000);
1681
1682 43836 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1683 43836 drop_item = vbound(ev[1] / 10000,-2,255);
1684 43836 thedropset = ev[2] / 10000;
1685 43836 ev.clear();
1686
1/2
✓ Branch 0 taken 43836 times.
✗ Branch 1 not taken.
43836 if(drop_item == -2)
1687 {
1688 drop_item = select_dropitem(thedropset,x,y);
1689 }
1690
1691
6/6
✓ Branch 0 taken 16545 times.
✓ Branch 1 taken 27291 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15628 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43836 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1692 {
1693 item* itm;
1694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16376 times.
16376 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1695 {
1696 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1697 }
1698 else
1699 {
1700
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1702 }
1703 16376 itm->from_dropset = thedropset;
1704 16376 add_item_for_screen(screen_spawned, itm);
1705
1706 16376 ev.push_back(getUID());
1707 16376 ev.push_back(itm->getUID());
1708
1709 16376 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1710 16376 ev.clear();
1711 16376 }
1712 43836 }
1713
1714 // auomatically kill off enemy (for rooms with ringleaders)
1715 411 void enemy::kickbucket()
1716 {
1717
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1718 379 hp=-1000; // don't call death_sfx()
1719 411 }
1720
1721 21250 bool enemy::isSubmerged() const
1722 {
1723 21250 return submerged;
1724 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1725 }
1726
1727 20952 void enemy::FireBreath(bool seekhero)
1728 {
1729
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1730 return;
1731
1732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1733 {
1734 dmisc1 = e1tEACHTILE;
1735 FireWeapon();
1736 return;
1737 }
1738
1739 20952 float fire_angle=0.0;
1740 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1741
1742
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1743 {
1744 xoff += hxofs;
1745 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1746 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1747 else
1748 xoff += (hit_width / 2) - 8;
1749 }
1750
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1751 {
1752 yoff += hyofs;
1753 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1754 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1755 else
1756 yoff += (hit_height / 2) - 8;
1757 }
1758
1759
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1760 {
1761
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1762 {
1763 case down:
1764 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1765 3079 wx=x;
1766 3079 wy=y+8;
1767 3079 break;
1768
1769 case -1:
1770 case up:
1771 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1772 3297 wx=x;
1773 3297 wy=y-8;
1774 3297 break;
1775
1776 case left:
1777 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1778 5287 wx=x-8;
1779 5287 wy=y;
1780 5287 break;
1781
1782 case right:
1783 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1784 4208 wx=x+8;
1785 4208 wy=y;
1786 4208 break;
1787 }
1788
1789
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1790 {
1791
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1797
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1798
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1799 15735 }
1800 15871 }
1801 else
1802 {
1803 5081 wx = x;
1804 5081 wy = y;
1805 }
1806
1807
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1808 20952 sfx(wpnsfx(wpn),pan(x));
1809
1810 20952 int32_t i=Ewpns.Count()-1;
1811 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1812 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1813
1814
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1815 {
1816 7957 ew->angular=true;
1817 7957 ew->angle=fire_angle;
1818 7957 }
1819
1820
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1821 {
1822 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1824 20359 }
1825
1826
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1827 {
1828 766199 Ewpns.swap(j,j-1);
1829 766199 }
1830 20952 }
1831
1832 44662 void enemy::FireWeapon()
1833 {
1834 /*
1835 * Type:
1836 * 0x01: Boss fireball
1837 * 0x02: Seeks Hero
1838 * 0x04: Fast projectile
1839 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1840 */
1841
1842
2/2
✓ Branch 0 taken 44531 times.
✓ Branch 1 taken 131 times.
44662 if (wpn < 1) return;
1843
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44531 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1844 return;
1845
1846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44531 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1847 dmisc1 = e1tEACHTILE;
1848
1849 44531 int32_t xoff = 0;
1850 44531 int32_t yoff = 0;
1851
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1852 {
1853 xoff += hxofs;
1854 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1855 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1856 else
1857 xoff += (hit_width / 2) - 8;
1858 }
1859
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1860 {
1861 yoff += hyofs;
1862 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1863 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1864 else
1865 yoff += (hit_height / 2) - 8;
1866 }
1867
1868 // TODO(crash): check that .add succeeds.
1869
1870
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41532 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44531 switch(dmisc1)
1871 {
1872 case e1t5SHOTS: //BS-Aquamentus
1873 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877
1878 [[fallthrough]];
1879 case e1t3SHOTSFAST:
1880 case e1t3SHOTS: //Aquamentus
1881
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1882 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1883
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
1886 [[fallthrough]];
1887 default:
1888
12/20
✓ Branch 0 taken 42178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42178 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42173 times.
✓ Branch 12 taken 42178 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23940 times.
✓ Branch 16 taken 42178 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42178 times.
✗ Branch 19 not taken.
42178 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1889 42178 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1890 42178 sfx(wpnsfx(wpn),pan(x));
1891 42178 break;
1892
1893 case e1tSLANT:
1894 {
1895 416 int32_t slant = 0;
1896
1897
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1898 246 slant = left;
1899
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1900 117 slant = right;
1901
1902
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1903 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1904 330 sfx(wpnsfx(wpn),pan(x));
1905 330 break;
1906 }
1907
1908 case e1t8SHOTS: //Fire Wizzrobe
1909
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1910 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1912
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1913 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1915
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1916 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1918
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1919 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1921
1922 [[fallthrough]];
1923 case e1t4SHOTS: //Stalfos 3
1924
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1925 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1927
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1928 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1930
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1931 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1933
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1934 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1936 1937 sfx(wpnsfx(wpn),pan(x));
1937 1937 break;
1938
1939 case e1tSUMMON: // Bat Wizzrobe
1940 {
1941 if(dmisc4==0) break; // Summon 0
1942
1943 int32_t bc=0;
1944
1945 for(int32_t gc=0; gc<guys.Count(); gc++)
1946 {
1947 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1948 {
1949 ++bc;
1950 }
1951 }
1952
1953 if(bc<=40) // Not too many enemies
1954 {
1955 int32_t kids = guys.Count();
1956 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1957
1958 for(int32_t i=0; i<bats; i++)
1959 {
1960 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1961 {
1962 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1963 }
1964 }
1965
1966 sfx(firesfx, pan(x));
1967 }
1968
1969 break;
1970 }
1971
1972 case e1tSUMMONLAYER: // Summoner
1973 {
1974 if(count_layer_enemies(screen_spawned)==0)
1975 {
1976 break;
1977 }
1978
1979 int32_t kids = guys.Count();
1980
1981 if(kids<40)
1982 {
1983 int32_t newguys=(zc_oldrand()%3)+1;
1984 bool summoned=false;
1985
1986 for(int32_t i=0; i<newguys; i++)
1987 {
1988 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1989 int32_t x2=0;
1990 int32_t y2=0;
1991
1992 for(int32_t k=0; k<20; ++k)
1993 {
1994 x2=16*((zc_oldrand()%12)+2);
1995 y2=16*((zc_oldrand()%7)+2);
1996
1997 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1998 {
1999 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2000 {
2001 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2002 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2003 {
2004 ((enemy*)guys.spr(kids+i))->fakez = 64;
2005 ((enemy*)guys.spr(kids+i))->z = 0;
2006 }
2007 }
2008
2009 summoned=true;
2010 break;
2011 }
2012 }
2013 }
2014
2015 if(summoned)
2016 {
2017 sfx(firesfx, pan(x));
2018 }
2019 }
2020
2021 break;
2022 }
2023 }
2024 44576 }
2025
2026
2027 // Hit the shield(s)?
2028 // Apparently, this function is only used for hookshots...
2029 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2030 {
2031
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2032 834 return false;
2033
2034 1933 bool ret = false;
2035
2036 // TODO: There must be some bitwise operations that can simplify this...
2037
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2038
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2039
2040
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2041
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2042
2043 1933 return ret;
2044 2767 }
2045
2046
2047 //! Weapon Editor for 2.6
2048 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2049
2050
2051 //converts a wqeapon ID to its defence index.
2052 127485 int32_t weaponToDefence(int32_t wid)
2053 {
2054
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64772 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4210 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127485 switch(wid)
2055 {
2056 case wNone: return -1;
2057 64772 case wSword: return edefSWORD;
2058 9439 case wBeam: return edefBEAM;
2059 25035 case wBrang: return edefBRANG;
2060 4210 case wBomb: return edefBOMB;
2061 37 case wSBomb: return edefSBOMB;
2062 48 case wLitBomb: return edefBOMB;
2063 case wLitSBomb: return edefSBOMB;
2064 3160 case wArrow: return edefARROW;
2065 9836 case wFire: return edefFIRE;
2066 case wWhistle:
2067 {
2068 return edefWhistle;
2069 }
2070 case wBait: return edefBAIT;
2071 269 case wWand: return edefWAND;
2072 1438 case wMagic: return edefMAGIC;
2073 case wCatching: return -1;
2074 case wWind: return edefWIND;
2075 512 case wRefMagic: return edefREFMAGIC;
2076 1459 case wRefFireball: return edefREFBALL;
2077 case wRefRock: return edefREFROCK;
2078 2054 case wHammer: return edefHAMMER;
2079 2767 case wHookshot: return edefHOOKSHOT;
2080 610 case wHSHandle: return edefHOOKSHOT;
2081 case wHSChain: return edefHOOKSHOT;
2082 240 case wSSparkle: return edefSPARKLE;
2083 469 case wFSparkle: return edefSPARKLE;
2084 case wSmack: return -1; // is this the candle object?
2085 case wPhantom: return -1; //engine created visual effects.
2086 case wCByrna: return edefBYRNA;
2087 19 case wRefBeam: return edefREFBEAM;
2088 case wStomp: return edefSTOMP;
2089 28 case wScript1: return edefSCRIPT01;
2090 case wScript2: return edefSCRIPT02;
2091 12 case wScript3: return edefSCRIPT03;
2092 77 case wScript4: return edefSCRIPT04;
2093 case wScript5: return edefSCRIPT05;
2094 case wScript6: return edefSCRIPT06;
2095 case wScript7: return edefSCRIPT07;
2096 case wScript8: return edefSCRIPT08;
2097 case wScript9: return edefSCRIPT09;
2098 993 case wScript10: return edefSCRIPT10;
2099 case wIce: return edefICE;
2100 case wSound: return edefSONIC;
2101 1 case wThrown: return edefTHROWN;
2102 case wRefArrow: return edefREFARROW;
2103 case wRefFire: return edefREFFIRE;
2104 case wRefFire2: return edefREFFIRE2;
2105 //case wPot: return edefPOT;
2106 // case wLitZap: return edefELECTRIC;
2107 // case wZ3Sword: return edefZ3SWORD;
2108 // case wLASWord: return edefLASWORD;
2109 // case wSpinAttk: return edefSPINATTK;
2110 // case wShield: return edefSHIELD;
2111 // case wTrowel: return edefTROWEL;
2112
2113 default: return -1;
2114 }
2115 127485 }
2116
2117 127485 int32_t getDefType(weapon *w)
2118 {
2119 127485 int32_t id = getWeaponID(w);
2120 127485 int32_t edef = weaponToDefence(id);
2121
2/2
✓ Branch 0 taken 124108 times.
✓ Branch 1 taken 3377 times.
127485 if(edef == edefHOOKSHOT)
2122 {
2123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2124 return edefSwitchHook;
2125 3377 }
2126 127485 return edef;
2127 127485 }
2128
2129 227168 int32_t getWeaponID(weapon *w)
2130 {
2131 227168 int32_t usewpn = w->useweapon;
2132
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226938 times.
227168 return (usewpn > 0) ? usewpn : w->id;
2133 }
2134
2135 127485 int32_t enemy::resolveEnemyDefence(weapon *w)
2136 {
2137 //sword edef is 9, but we're reading it at 0
2138 //,
2139 127485 int32_t weapondef = 0;
2140 127485 int32_t wdeftype = getDefType(w);
2141 127485 int32_t usedef = w->usedefense;
2142
2143
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127485 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2144 {
2145 weapondef = usedef*-1;
2146 }
2147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
127485 else if(unsigned(wdeftype) < edefLAST255)
2148 {
2149 127485 weapondef = wdeftype;
2150 127485 }
2151 127485 return weapondef;
2152 }
2153
2154 138087 byte get_def_ignrflag(int32_t edef)
2155 {
2156
3/3
✓ Branch 0 taken 115117 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
138087 switch(edef)
2157 {
2158 case edIGNORE:
2159 case edIGNOREL1:
2160 case edSTUNORIGNORE:
2161 19287 return WPNUNB_IGNR;
2162 case edSTUNORCHINK:
2163 case edCHINK:
2164 case edCHINKL1:
2165 case edCHINKL2:
2166 case edCHINKL4:
2167 case edCHINKL6:
2168 case edCHINKL8:
2169 case edCHINKL10:
2170 case edLEVELCHINK2:
2171 case edLEVELCHINK3:
2172 case edLEVELCHINK4:
2173 case edLEVELCHINK5:
2174 3683 return WPNUNB_BLOCK;
2175 }
2176 115117 return 0;
2177 138087 }
2178
2179 138087 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2180 {
2181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138087 times.
138087 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2182 switch(edef)
2183 {
2184 case edIGNORE:
2185 case edIGNOREL1:
2186 case edCHINK:
2187 case edCHINKL1:
2188 case edCHINKL2:
2189 case edCHINKL4:
2190 case edCHINKL6:
2191 case edCHINKL8:
2192 case edCHINKL10:
2193 case edLEVELCHINK2:
2194 case edLEVELCHINK3:
2195 case edLEVELCHINK4:
2196 case edLEVELCHINK5:
2197 return edNORMAL;
2198 case edSTUNORIGNORE:
2199 case edSTUNORCHINK:
2200 return edSTUNONLY;
2201 }
2202 return edef;
2203 138087 }
2204
2205 // Do we do damage?
2206 // 0: takehit returns 0
2207 // 1: takehit returns 1
2208 // -1: do damage
2209 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2210 126492 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2211 {
2212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(switch_hooked) return 0;
2213 126492 int32_t tempx = x;
2214 126492 int32_t tempy = y;
2215 126492 int32_t the_defence = 0;
2216
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2217 {
2218 the_defence = edef*-1; //A specific defence type.
2219 }
2220 126492 else the_defence = defense[edef];
2221
2222 126492 the_defence = conv_edef_unblockable(the_defence, unblockable);
2223
2224
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119869 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126492 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2225 {
2226
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2227 {
2228 case edIGNORE:
2229 7 return 0;
2230 case edIGNOREL1:
2231 case edSTUNORIGNORE:
2232 if(*power <= 0)
2233 return 0;
2234 }
2235 6616 sfx(WAV_CHINK,pan(x));
2236 6616 return 1;
2237 }
2238
2239 119869 int32_t new_id = id;
2240 119869 int32_t effect_type = dmisc15;
2241 119869 int32_t delay_timer = 90;
2242 119869 enemy *gleeok = NULL;
2243 119869 enemy *ptra = NULL;
2244 119869 int32_t c = 0;
2245
2246
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93608 times.
119869 switch(the_defence)
2247 {
2248 case edREPLACE:
2249 {
2250 sclk = 0;
2251 if ( dmisc16 > 0 ) new_id = dmisc16;
2252 else new_id = id+1;
2253 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2254 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2255 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2256
2257 //Z_scripterrlog("new id is %d\n", new_id);
2258 switch(guysbuf[new_id&0xFFF].type)
2259 {
2260 //Fixme: possible enemy memory leak. (minor)
2261 case eeWALK:
2262 {
2263 enemy *e = new eStalfos(x,y,new_id,clk);
2264 guys.add(e);
2265 }
2266 break;
2267
2268 case eeLEV:
2269 {
2270 enemy *e = new eLeever(x,y,new_id,clk);
2271 guys.add(e);
2272 }
2273 break;
2274
2275 case eeTEK:
2276 {
2277 enemy *e = new eTektite(x,y,new_id,clk);
2278 guys.add(e);
2279 }
2280 break;
2281
2282 case eePEAHAT:
2283 {
2284 enemy *e = new ePeahat(x,y,new_id,clk);
2285 guys.add(e);
2286 }
2287 break;
2288
2289 case eeZORA:
2290 {
2291 enemy *e = new eZora(x,y,new_id,clk);
2292 guys.add(e);
2293 }
2294 break;
2295
2296 case eeGHINI:
2297 {
2298 enemy *e = new eGhini(x,y,new_id,clk);
2299 guys.add(e);
2300 }
2301 break;
2302
2303 case eeKEESE:
2304 {
2305 enemy *e = new eKeese(x,y,new_id,clk);
2306 guys.add(e);
2307 }
2308 break;
2309
2310 case eeWIZZ:
2311 {
2312 enemy *e = new eWizzrobe(x,y,new_id,clk);
2313 guys.add(e);
2314 }
2315 break;
2316
2317 case eePROJECTILE:
2318 {
2319 enemy *e = new eProjectile(x,y,new_id,clk);
2320 guys.add(e);
2321 }
2322 break;
2323
2324 case eeWALLM:
2325 {
2326 enemy *e = new eWallM(x,y,new_id,clk);
2327 guys.add(e);
2328 }
2329 break;
2330
2331 case eeAQUA:
2332 {
2333 enemy *e = new eAquamentus(x,y,new_id,clk);
2334 guys.add(e);
2335 e->x = x;
2336 e->y = y;
2337 }
2338 break;
2339
2340 case eeMOLD:
2341 {
2342 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2343 guys.add(e);
2344 e->x = x;
2345 e->y = y;
2346 }
2347 break;
2348
2349 case eeMANHAN:
2350 {
2351 enemy *e = new eManhandla(x,y,new_id,clk);
2352 guys.add(e);
2353 e->x = x;
2354 e->y = y;
2355 }
2356 break;
2357
2358 case eeGLEEOK:
2359 {
2360 *power = 0;
2361 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2362 guys.add(gleeok);
2363 // TODO(crash): check that .add succeeds.
2364 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2365 new_id &= 0xFFF;
2366 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2367 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2368 for(int32_t i=0; i<head_cnt; i++)
2369 {
2370 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2371 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2372 {
2373 al_trace("Gleeok head %d could not be created!\n",i+1);
2374
2375 for(int32_t j=0; j<i+1; j++)
2376 {
2377 guys.del(guys.Count()-1);
2378 }
2379
2380 break;
2381 }
2382 else
2383 {
2384 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2385 }
2386
2387 c-=guysbuf[new_id].attributes[3];
2388 }
2389 return 1;
2390 }
2391
2392 case eeGHOMA:
2393 {
2394 enemy *e = new eGohma(x,y,new_id,clk);
2395 guys.add(e);
2396 e->x = x;
2397 e->y = y;
2398 }
2399 break;
2400
2401 case eeLANM:
2402 {
2403 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2404 guys.add(e);
2405 e->x = x;
2406 e->y = y;
2407 }
2408 break;
2409
2410 case eeGANON:
2411 {
2412 enemy *e = new eGanon(x,y,new_id,clk);
2413 guys.add(e);
2414 e->x = x;
2415 e->y = y;
2416 }
2417 break;
2418
2419 case eeFAIRY:
2420 {
2421 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2422 guys.add(e);
2423 e->x = x;
2424 e->y = y;
2425 }
2426 break;
2427
2428 case eeFIRE:
2429 {
2430 enemy *e = new eFire(x,y,new_id,clk);
2431 guys.add(e);
2432 e->x = x;
2433 e->y = y;
2434 }
2435 break;
2436
2437 case eeOTHER:
2438 {
2439 enemy *e = new eOther(x,y,new_id,clk);
2440 guys.add(e);
2441 e->x = x;
2442 e->y = y;
2443 }
2444 break;
2445
2446 case eeSPINTILE:
2447 {
2448 enemy *e = new eSpinTile(x,y,new_id,clk);
2449 guys.add(e);
2450 e->x = x;
2451 e->y = y;
2452 }
2453 break;
2454
2455 // and these enemies use the misc10/misc2 value
2456 case eeROCK:
2457 {
2458 switch(guysbuf[new_id&0xFFF].attributes[9])
2459 {
2460 case 1:
2461 {
2462 enemy *e = new eBoulder(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 case 0:
2470 default:
2471 {
2472 enemy *e = new eRock(x,y,new_id,clk);
2473 guys.add(e);
2474 e->x = x;
2475 e->y = y;
2476 }
2477 break;
2478 }
2479
2480 break;
2481 }
2482
2483 case eeTRAP:
2484 {
2485 switch(guysbuf[new_id&0xFFF].attributes[1])
2486 {
2487 case 1:
2488 {
2489 enemy *e = new eTrap2(x,y,new_id,clk);
2490 guys.add(e);
2491 e->x = x;
2492 e->y = y;
2493 }
2494 break;
2495
2496 case 0:
2497 default:
2498 {
2499 enemy *e = new eTrap(x,y,new_id,clk);
2500 guys.add(e);
2501 e->x = x;
2502 e->y = y;
2503 }
2504 break;
2505 }
2506
2507 break;
2508 }
2509
2510 case eeDONGO:
2511 {
2512 switch(guysbuf[new_id&0xFFF].attributes[9])
2513 {
2514 case 1:
2515 {
2516 enemy *e = new eDodongo2(x,y,new_id,clk);
2517 guys.add(e);
2518 e->x = x;
2519 e->y = y;
2520 }
2521 break;
2522
2523 case 0:
2524 default:
2525 {
2526 enemy *e = new eDodongo(x,y,new_id,clk);
2527 guys.add(e);
2528 e->x = x;
2529 e->y = y;
2530 }
2531 break;
2532 }
2533
2534 break;
2535 }
2536
2537 case eeDIG:
2538 {
2539 switch(guysbuf[new_id&0xFFF].attributes[9])
2540 {
2541 case 1:
2542 {
2543 enemy *e = new eLilDig(x,y,new_id,clk);
2544 guys.add(e);
2545 e->x = x;
2546 e->y = y;
2547 }
2548 break;
2549
2550 case 0:
2551 default:
2552 {
2553 enemy *e = new eBigDig(x,y,new_id,clk);
2554 guys.add(e);
2555 e->x = x;
2556 e->y = y;
2557 }
2558 break;
2559 }
2560
2561 break;
2562 }
2563
2564 case eePATRA:
2565 {
2566 switch(guysbuf[new_id&0xFFF].attributes[9])
2567 {
2568 case 1:
2569 {
2570 if (get_qr(qr_HARDCODED_BS_PATRA))
2571 {
2572 enemy *e = new ePatraBS(x,y,new_id,clk);
2573 guys.add(e);
2574 e->x = x;
2575 e->y = y;
2576 break;
2577 }
2578 }
2579 [[fallthrough]];
2580 case 0:
2581 default:
2582 {
2583 enemy *e = new ePatra(x,y,new_id,clk);
2584 guys.add(e);
2585 e->x = x;
2586 e->y = y;
2587 }
2588 break;
2589 }
2590
2591 break;
2592 }
2593
2594 case eeGUY:
2595 {
2596 switch(guysbuf[new_id&0xFFF].attributes[9])
2597 {
2598 case 1:
2599 {
2600 enemy *e = new eTrigger(x,y,new_id,clk);
2601 guys.add(e);
2602 }
2603 break;
2604
2605 case 0:
2606 default:
2607 {
2608 enemy *e = new eNPC(x,y,new_id,clk);
2609 guys.add(e);
2610 }
2611 break;
2612 }
2613
2614 break;
2615 }
2616
2617 case eeSCRIPT01:
2618 case eeSCRIPT02:
2619 case eeSCRIPT03:
2620 case eeSCRIPT04:
2621 case eeSCRIPT05:
2622 case eeSCRIPT06:
2623 case eeSCRIPT07:
2624 case eeSCRIPT08:
2625 case eeSCRIPT09:
2626 case eeSCRIPT10:
2627 case eeSCRIPT11:
2628 case eeSCRIPT12:
2629 case eeSCRIPT13:
2630 case eeSCRIPT14:
2631 case eeSCRIPT15:
2632 case eeSCRIPT16:
2633 case eeSCRIPT17:
2634 case eeSCRIPT18:
2635 case eeSCRIPT19:
2636 case eeSCRIPT20:
2637 {
2638 enemy *e = new eScript(x,y,new_id,clk);
2639 guys.add(e);
2640 e->x = x;
2641 e->y = y;
2642 break;
2643 }
2644
2645
2646 case eeFFRIENDLY01:
2647 case eeFFRIENDLY02:
2648 case eeFFRIENDLY03:
2649 case eeFFRIENDLY04:
2650 case eeFFRIENDLY05:
2651 case eeFFRIENDLY06:
2652 case eeFFRIENDLY07:
2653 case eeFFRIENDLY08:
2654 case eeFFRIENDLY09:
2655 case eeFFRIENDLY10:
2656 {
2657 enemy *e = new eFriendly(x,y,new_id,clk);
2658 guys.add(e);
2659 e->x = x;
2660 e->y = y;
2661 break;
2662 }
2663
2664
2665 default: break;
2666 }
2667
2668 // add segments of segmented enemies
2669 int32_t c=0;
2670
2671 switch(guysbuf[new_id&0xFFF].type)
2672 {
2673 case eeMOLD:
2674 {
2675 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2676 new_id &= 0xFFF;
2677
2678 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2679 {
2680 //christ this is messy -DD
2681 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2682
2683 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2684 {
2685 al_trace("Moldorm segment %d could not be created!\n",i+1);
2686
2687 for(int32_t j=0; j<i+1; j++)
2688 guys.del(guys.Count()-1);
2689
2690 return 0;
2691 }
2692
2693 if(i>0)
2694 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2695
2696
2697 }
2698
2699 break;
2700 }
2701
2702 case eeLANM:
2703 {
2704 new_id &= 0xFFF;
2705 int32_t shft = guysbuf[new_id].attributes[1];
2706 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2707 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2708
2709 if(!guys.add(e))
2710 {
2711 al_trace("Lanmola segment 1 could not be created!\n");
2712 guys.del(guys.Count()-1);
2713 return 0;
2714 }
2715 e->x = x;
2716 e->y = y;
2717
2718
2719
2720 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2721 {
2722 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2723 if(!guys.add(e2))
2724 {
2725 al_trace("Lanmola segment %d could not be created!\n",i+1);
2726
2727 for(int32_t j=0; j<i+1; j++)
2728 guys.del(guys.Count()-1);
2729
2730 return 0;
2731 }
2732 e2->x = x;
2733 e2->y = y;
2734
2735 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2736
2737 }
2738 }
2739 break;
2740
2741 case eeMANHAN:
2742 new_id &= 0xFFF;
2743
2744 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2745 {
2746 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2747 {
2748 al_trace("Manhandla head %d could not be created!\n",i+1);
2749
2750 for(int32_t j=0; j<i+1; j++)
2751 {
2752 guys.del(guys.Count()-1);
2753 }
2754
2755 return 0;
2756 }
2757
2758
2759 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2760 }
2761
2762 break;
2763
2764 case eeGLEEOK:
2765 {
2766 /*
2767 new_id &= 0xFFF;
2768 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2769 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2770 for(int32_t i=0; i<head_cnt; i++)
2771 {
2772 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2773 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2774 {
2775 al_trace("Gleeok head %d could not be created!\n",i+1);
2776
2777 for(int32_t j=0; j<i+1; j++)
2778 {
2779 guys.del(guys.Count()-1);
2780 }
2781
2782 break;
2783 }
2784
2785 c-=guysbuf[new_id].misc4;
2786 */
2787
2788 // }
2789 }
2790 break;
2791
2792
2793 case eePATRA:
2794 {
2795 new_id &= 0xFFF;
2796 int32_t outeyes = 0;
2797 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2798
2799 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2800 {
2801 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2802 {
2803 al_trace("Patra outer eye %d could not be created!\n",i+1);
2804
2805 for(int32_t j=0; j<i+1; j++)
2806 guys.del(guys.Count()-1);
2807
2808 return 0;
2809 }
2810 else
2811 outeyes++;
2812
2813
2814 }
2815
2816 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2817 {
2818 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2819 {
2820 al_trace("Patra inner eye %d could not be created!\n",i+1);
2821
2822 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2823 guys.del(guys.Count()-1);
2824
2825 return 0;
2826 }
2827
2828
2829 }
2830 delete ptra;
2831 break;
2832 }
2833 }
2834
2835
2836 // TODO(crash): check that the above .add succeeded.
2837 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2838 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2839 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2840 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2841 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2842 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2843 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2844 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2845 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2846 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2847 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2848 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2849
2850
2851 item_set = 0; //Do not make a drop.
2852
2853 switch(effect_type)
2854 {
2855 case -7:
2856 {
2857 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2858 Lwpns.add(w);
2859 break;
2860 }
2861 case -6:
2862 {
2863 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2864 Lwpns.add(w);
2865 break;
2866 }
2867 case -5:
2868 {
2869 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2870 Lwpns.add(w);
2871 break;
2872 }
2873 case -4:
2874 {
2875 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2876 Lwpns.add(w);
2877 break;
2878 }
2879 case -3: explode(1); break;
2880 case -2: explode(2); break;
2881 case -1: explode(0); break;
2882 case 0: break;
2883
2884 default:
2885 {
2886 //Dummy weapon function
2887 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2888 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 }
2893
2894
2895 yofs = -32768;
2896 switch(guysbuf[new_id&0xFFF].type)
2897 {
2898 case eeGLEEOK:
2899 {
2900 Z_scripterrlog("Replacing a gleeok.\n");
2901 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2902 hp = -999;
2903 if (tempenemy) tempenemy->hp = -999;
2904 break;
2905
2906 }
2907 default:
2908 hp = -1000; break;
2909 }
2910 int mi = mapind(cur_map, screen_spawned);
2911 ++game->guys[mi];
2912 return 1;
2913
2914 }
2915 case edSPLIT:
2916 {
2917 for ( int32_t q = 0; q < dmisc4; q++ )
2918 {
2919 addenemy(screen_spawned,x,y,
2920 dmisc3+0x1000,-15);
2921
2922 }
2923 item_set = 0; //Do not make a drop.
2924 hp = -1000;
2925 return -1;
2926
2927 }
2928 case edSUMMON:
2929 {
2930 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2931 for ( int32_t q = 0; q < summon_count; q++ )
2932 {
2933 int32_t x2=16*((zc_oldrand()%12)+2);
2934 int32_t y2=16*((zc_oldrand()%7)+2);
2935 addenemy(screen_spawned,
2936 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2937 x2,y2,
2938 dmisc3+0x1000,-15);
2939
2940 }
2941 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2942 return -1;
2943
2944 }
2945
2946 case edEXPLODESMALL:
2947 {
2948 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2949 Ewpns.add(ew);
2950 item_set = 0; //Should we make a drop?
2951 hp = -1000;
2952 return -1;
2953 }
2954
2955
2956 case edEXPLODEHARMLESS:
2957 {
2958 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2959 Ewpns.add(ew);
2960 ew->hyofs = -32768;
2961 item_set = 0; //Should we make a drop?
2962 hp = -1000;
2963 return -1;
2964 }
2965
2966
2967 case edEXPLODELARGE:
2968 {
2969 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2970 Ewpns.add(ew);
2971
2972 hp = -1000;
2973 return -1;
2974 }
2975
2976
2977 case edTRIGGERSECRETS:
2978 {
2979 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2980 return -1;
2981 }
2982
2983 case edSTUNORCHINK:
2984
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2985 {
2986 649 sfx(WAV_CHINK,pan(x));
2987 649 return 1;
2988 }
2989
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2990 {
2991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2992 return 0;
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2994 {
2995 sfx(WAV_CHINK,pan(x));
2996 return 1;
2997 }
2998 1119 }
2999 [[fallthrough]];
3000
3001 case edSTUNORIGNORE:
3002
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3003 955 return 0;
3004
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3007 return 0;
3008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3009 {
3010 sfx(WAV_CHINK,pan(x));
3011 return 1;
3012 }
3013 1952 }
3014 [[fallthrough]];
3015
3016 case edSTUNONLY:
3017
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3018 {
3019 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3020 321 return 1;
3021 }
3022
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 3118 times.
4043 if (stunclk)
3023 {
3024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3025 return 0;
3026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3027 {
3028 sfx(WAV_CHINK,pan(x));
3029 return 1;
3030 }
3031 3118 }
3032 4043 stunclk=160;
3033 4043 sfx(WAV_EHIT,pan(x));
3034 4043 return 1;
3035
3036 case edCHINKL1:
3037 if(*power >= 1*game->get_hero_dmgmult()) break;
3038 [[fallthrough]];
3039 case edCHINKL2:
3040
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3041 [[fallthrough]];
3042 case edCHINKL4:
3043
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3044 [[fallthrough]];
3045 case edCHINKL6:
3046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3047 [[fallthrough]];
3048 case edCHINKL8:
3049
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3050 [[fallthrough]];
3051 case edCHINKL10:
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3053 [[fallthrough]];
3054 case edCHINK:
3055 1056 sfx(WAV_CHINK,pan(x));
3056 1056 return 1;
3057
3058 case edIGNOREL1:
3059 if(*power > 0) break;
3060 [[fallthrough]];
3061
3062 case edIGNORE:
3063 17349 return 0;
3064
3065 case ed1HKO:
3066 492 *power = hp;
3067 492 return -3;
3068
3069 case ed2x:
3070 {
3071
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3072 //int32_t pow = *power;
3073 //*power = vbound((pow*2),0,214747);
3074 71 return -1;
3075 }
3076 case ed3x:
3077 {
3078 *power = zc_max(1,*power*3);
3079 //int32_t pow = *power;
3080 //*power = vbound((pow*3),0,214747);
3081 return -1;
3082 }
3083
3084 case ed4x:
3085 {
3086 *power = zc_max(1,*power*4);
3087 //int32_t pow = *power;
3088 //*power = vbound((pow*4),0,214747);
3089 return -1;
3090 }
3091
3092
3093 case edHEAL:
3094 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3095 //int32_t pow = *power;
3096 //*power = vbound((pow*-1),0,214747);
3097 //break;
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3099 158 return -1;
3100 }
3101 /*
3102 case edLEVELDAMAGE:
3103 {
3104 int32_t pow = *power;
3105 int32_t lvl = *level;
3106 *power = vbound((pow*lvl),0,214747);
3107 break;
3108 }
3109 case edLEVELREDUCTION:
3110 {
3111 int32_t pow = *power;
3112 int32_t lvl = *level;
3113 *power = vbound((pow/lvl),0,214747);
3114 break;
3115 }
3116 */
3117
3118 case edQUARTDAMAGE:
3119
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3120
3121 [[fallthrough]];
3122 case edHALFDAMAGE:
3123
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3124 988 break;
3125
3126 case edSWITCH:
3127 {
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3130 {
3131 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3132 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3133 return 0;
3134 }
3135 4 hooked_comborpos = rpos_t::None;
3136 4 hooked_layerbits = 0;
3137 4 switching_object = this;
3138 4 switch_hooked = true;
3139 4 Hero.doSwitchHook(game->get_switchhookstyle());
3140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3141 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3142 4 return 1;
3143 }
3144
3145 case 0:
3146 {
3147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93608 times.
93608 if(edef == edefSwitchHook)
3148 return -1;
3149
4/4
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 74076 times.
✓ Branch 2 taken 7756 times.
✓ Branch 3 taken 11776 times.
93608 if (stunclk && *power == 0)
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3152 return 0;
3153
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11750 times.
11776 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3154 {
3155 26 sfx(WAV_CHINK,pan(x));
3156 26 return 1;
3157 }
3158 11750 }
3159 93582 break;
3160 }
3161 }
3162
3163 94745 return -1;
3164 126492 }
3165
3166 126492 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3167 {
3168
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 int wuid = w?w->getUID():0;
3169
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3170
3171
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3172 Lwpns.add(w);
3173 126492 std::vector<int32_t> &ev = FFCore.eventData;
3174 126492 ev.clear();
3175 126492 ev.push_back(*power*10000);
3176 126492 ev.push_back(edef*10000);
3177 126492 ev.push_back(unblockable*10000);
3178 126492 ev.push_back(wpnId*10000);
3179 126492 ev.push_back(0);
3180 126492 ev.push_back(getUID());
3181 126492 ev.push_back(wuid);
3182
3183 126492 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3184 126492 *power = ev[0]/10000;
3185 126492 edef = ev[1]/10000;
3186 126492 unblockable = byte(ev[2]/10000);
3187 126492 wpnId = ev[3] / 10000;
3188 126492 bool nullify = ev[4]!=0;
3189 126492 ev.clear();
3190 126492 int ret = 0;
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(!nullify)
3192 {
3193 126492 ret = defendNew(wpnId, power, edef, unblockable);
3194
2/2
✓ Branch 0 taken 32388 times.
✓ Branch 1 taken 94104 times.
126492 if(ret < 0)
3195 {
3196 94104 ev.push_back(*power*10000);
3197 94104 ev.push_back(edef*10000);
3198 94104 ev.push_back(unblockable*10000);
3199 94104 ev.push_back(wpnId*10000);
3200 94104 ev.push_back(0);
3201 94104 ev.push_back(getUID());
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94104 times.
94104 ev.push_back(w?w->getUID():0);
3203
3204 94104 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3205 94104 *power = ev[0]/10000;
3206 94104 nullify = ev[4]!=0;
3207 94104 ev.clear();
3208 94104 }
3209 126492 }
3210
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3211 Lwpns.remove(w);
3212
3213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 return nullify ? 0 : ret;
3214 }
3215
3216 99683 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3217 {
3218
2/2
✓ Branch 0 taken 99106 times.
✓ Branch 1 taken 577 times.
99683 if(!realweap) realweap = w;
3219 99683 int32_t wid = getWeaponID(w);
3220
3221 99683 int32_t edef = resolveEnemyDefence(w);
3222
2/2
✓ Branch 0 taken 6268 times.
✓ Branch 1 taken 93415 times.
99683 if(QHeader.zelda_version > 0x250)
3223 6268 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3224
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3225 {
3226 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3227 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3228 993 return defend(wpnId, power, edefSCRIPT);
3229
3230 case wWhistle:
3231 return -1;
3232
3233 default:
3234 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3235 }
3236 99683 }
3237
3238
3239 // Check defenses without actually acting on them.
3240 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3241 {
3242
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3243 {
3244 case edSTUNONLY:
3245 474 return false;
3246 case edSTUNORCHINK:
3247 case edCHINK:
3248 15409 return unblockable&WPNUNB_BLOCK;
3249 case edSTUNORIGNORE:
3250 case edIGNORE:
3251 11050 return unblockable&WPNUNB_IGNR;
3252
3253 case edIGNOREL1:
3254 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3255 case edCHINKL1:
3256 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3257
3258 case edCHINKL2:
3259 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3260
3261 case edCHINKL4:
3262 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3263
3264 case edCHINKL6:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3266
3267 case edCHINKL8:
3268 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3269 }
3270
3271 469 return true;
3272 27402 }
3273
3274 // Do we do damage?
3275 // 0: takehit returns 0
3276 // 1: takehit returns 1
3277 // -1: do damage
3278 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3279 {
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3281 {
3282 switch(defense[edef])
3283 {
3284 case edIGNORE:
3285 return 0;
3286 case edIGNOREL1:
3287 case edSTUNORIGNORE:
3288 if(*power <= 0)
3289 return 0;
3290 }
3291
3292 sfx(WAV_CHINK,pan(x));
3293 return 1;
3294 }
3295
3296
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3297 {
3298 case edSTUNORCHINK:
3299 if(*power <= 0)
3300 {
3301 sfx(WAV_CHINK,pan(x));
3302 return 1;
3303 }
3304
3305 [[fallthrough]];
3306 case edSTUNORIGNORE:
3307 if(*power <= 0)
3308 return 0;
3309
3310 [[fallthrough]];
3311 case edSTUNONLY:
3312 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3313 return 1;
3314
3315 stunclk=160;
3316 sfx(WAV_EHIT,pan(x));
3317 return 1;
3318
3319 case edFREEZE:
3320 frozenclock=-1;
3321 //sfx(WAV_FREEZE,pan(x));
3322 return 1;
3323
3324 case edCHINKL1:
3325 if(*power >= 1*game->get_hero_dmgmult()) break;
3326 [[fallthrough]];
3327 case edCHINKL2:
3328 if(*power >= 2*game->get_hero_dmgmult()) break;
3329 [[fallthrough]];
3330 case edCHINKL4:
3331 if(*power >= 4*game->get_hero_dmgmult()) break;
3332 [[fallthrough]];
3333 case edCHINKL6:
3334 if(*power >= 6*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL8:
3337 if(*power >= 8*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINKL10:
3340 if(*power >= 10*game->get_hero_dmgmult()) break;
3341 [[fallthrough]];
3342 case edCHINK:
3343 sfx(WAV_CHINK,pan(x));
3344 return 1;
3345 case edTRIGGERSECRETS:
3346 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3347 break;
3348
3349 case edIGNOREL1:
3350 if(*power > 0) break;
3351 [[fallthrough]];
3352 case edIGNORE:
3353 800 return 0;
3354
3355 case ed1HKO:
3356 *power = hp;
3357 return -3;
3358
3359 case ed2x:
3360 {
3361 *power = zc_max(1,*power*2);
3362 //int32_t pow = *power;
3363 //*power = vbound((pow*2),0,214747);
3364 return -1;
3365 }
3366 case ed3x:
3367 {
3368 *power = zc_max(1,*power*3);
3369 //int32_t pow = *power;
3370 //*power = vbound((pow*3),0,214747);
3371 return -1;
3372 }
3373
3374 case ed4x:
3375 {
3376 *power = zc_max(1,*power*4);
3377 //int32_t pow = *power;
3378 //*power = vbound((pow*4),0,214747);
3379 return -1;
3380 }
3381
3382
3383 case edHEAL:
3384 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3385 //int32_t pow = *power;
3386 //*power = vbound((pow*-1),0,214747);
3387 //break;
3388 *power = zc_min(0,*power*-1);
3389 return -1;
3390 }
3391 /*
3392 case edLEVELDAMAGE:
3393 {
3394 int32_t pow = *power;
3395 int32_t lvl = *level;
3396 *power = vbound((pow*lvl),0,214747);
3397 break;
3398 }
3399 case edLEVELREDUCTION:
3400 {
3401 int32_t pow = *power;
3402 int32_t lvl = *level;
3403 *power = vbound((pow/lvl),0,214747);
3404 break;
3405 }
3406 */
3407
3408
3409 case edQUARTDAMAGE:
3410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3411
3412 [[fallthrough]];
3413 case edHALFDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415 7 break;
3416 }
3417
3418 193 return -1;
3419 993 }
3420
3421 // Defend against a particular item class.
3422 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3423 {
3424 int32_t def=-1;
3425
3426 switch(wpnId)
3427 {
3428 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3429 case wBrang:
3430 def = defend(wpnId, power, edefBRANG);
3431 break;
3432
3433 case wHookshot:
3434 def = defend(wpnId, power, edefHOOKSHOT);
3435 break;
3436
3437 // Anyway...
3438 case wBomb:
3439 def = defend(wpnId, power, edefBOMB);
3440 break;
3441
3442 case wSBomb:
3443 def = defend(wpnId, power, edefSBOMB);
3444 break;
3445
3446 case wArrow:
3447 def = defend(wpnId, power, edefARROW);
3448 break;
3449
3450 case wFire:
3451 def = defend(wpnId, power, edefFIRE);
3452 break;
3453
3454 case wWand:
3455 def = defend(wpnId, power, edefWAND);
3456 break;
3457
3458 case wMagic:
3459 def = defend(wpnId, power, edefMAGIC);
3460 break;
3461
3462 case wHammer:
3463 def = defend(wpnId, power, edefHAMMER);
3464 break;
3465
3466 case wSword:
3467 def = defend(wpnId, power, edefSWORD);
3468 break;
3469
3470 case wBeam:
3471 def = defend(wpnId, power, edefBEAM);
3472 break;
3473
3474 case wRefBeam:
3475 def = defend(wpnId, power, edefREFBEAM);
3476 break;
3477
3478 case wRefMagic:
3479 def = defend(wpnId, power, edefREFMAGIC);
3480 break;
3481
3482 case wRefFireball:
3483 def = defend(wpnId, power, edefREFBALL);
3484 break;
3485
3486 case wRefRock:
3487 def = defend(wpnId, power, edefREFROCK);
3488 break;
3489
3490 case wStomp:
3491 def = defend(wpnId, power, edefSTOMP);
3492 break;
3493
3494 case wCByrna:
3495 def = defend(wpnId, power, edefBYRNA);
3496 break;
3497
3498 case wScript1:
3499 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3500 else def = defend(wpnId, power, edefSCRIPT);
3501 break;
3502
3503 case wScript2:
3504 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3505 else def = defend(wpnId, power, edefSCRIPT);
3506 break;
3507
3508 case wScript3:
3509 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3510 else def = defend(wpnId, power, edefSCRIPT);
3511 break;
3512
3513 case wScript4:
3514 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3515 else def = defend(wpnId, power, edefSCRIPT);
3516 break;
3517
3518 case wScript5:
3519 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3520 else def = defend(wpnId, power, edefSCRIPT);
3521 break;
3522
3523 case wScript6:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript7:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript8:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript9:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript10:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wWhistle:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3550 else break;
3551 break;
3552
3553 case wRefArrow:
3554 def = defend(wpnId, power, edefREFARROW);
3555 break;
3556 case wRefFire:
3557 def = defend(wpnId, power, edefREFFIRE);
3558 break;
3559 case wRefFire2:
3560 def = defend(wpnId, power, edefREFFIRE2);
3561 break;
3562
3563 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3564 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3565 //of the ten if the quest version is lower than N.
3566 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3567 //such as bool UseSeparatedScriptDefences. hah.
3568 default:
3569 //if(wpnId>=wScript1 && wpnId<=wScript10)
3570 // {
3571 // def = defend(wpnId, power, edefSCRIPT);
3572 // }
3573 // }
3574
3575 break;
3576 }
3577
3578 return def;
3579 }
3580
3581 // take damage or ignore it
3582 // 2 or -2: force wait a frame
3583 // < 0: damage (if any) dealt
3584 // > 0: blocked
3585 // 0: weapon passes through unhindered
3586 265281 int32_t enemy::takehit(weapon *w, weapon* realweap)
3587 {
3588
2/4
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265281 times.
265281 if(fallclk||drownclk) return 0;
3589
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 195507 times.
265281 if(!realweap) realweap = w;
3590 265281 int32_t wpnId = w->id;
3591 265281 int32_t power = w->power;
3592 265281 int32_t wpnx = w->x;
3593 265281 int32_t wpny = w->y;
3594 265281 int32_t enemyHitWeapon = w->parentitem;
3595 int32_t wpnDir;
3596 265281 int32_t parent_item = w->parentitem;
3597
3598
2/2
✓ Branch 0 taken 265166 times.
✓ Branch 1 taken 115 times.
265281 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3599 {
3600 115 wpnId = w->useweapon;
3601 115 }
3602
3603 // If it's a boomerang that just bounced, use the opposite direction;
3604 // otherwise, it might bypass a shield. This probably won't handle
3605 // every case correctly, but it's better than having shields simply
3606 // not work against boomerangs.
3607
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 240200 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265281 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3608 11056 wpnDir = oppositeDir[w->dir];
3609 else
3610 254225 wpnDir = w->dir;
3611
3612
5/8
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8058 times.
✓ Branch 7 taken 272607 times.
265281 if(dying || clk<0 || hclk>0 || superman)
3613 8058 return 0;
3614
3615 //Prevent boomerang from writing to hitby[] for more than one frame.
3616 //This also prevents stunlock.
3617 //if ( stunclk > 0 ) return 0;
3618 //this needs a rule for boomerangs that cannot stunlock!
3619 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3620 //sigh.
3621
3622 272607 int32_t ret = -1;
3623
3624 // This obscure quest rule...
3625
5/6
✓ Branch 0 taken 92333 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 88830 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88830 times.
272607 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3626 {
3627 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3628 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3629 3503 wpnDir=zc_oldrand()&3;
3630
3631
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3632 {
3633 189 wpnDir=down;
3634 189 }
3635
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3636 {
3637 285 wpnDir=right;
3638 285 }
3639
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3640 {
3641 2064 wpnDir=up;
3642 2064 }
3643 else
3644 {
3645 965 wpnDir=left;
3646 }
3647 3503 }
3648
3649 272607 int32_t xdir = dir;
3650 272607 shieldCanBlock=false;
3651
3652
4/4
✓ Branch 0 taken 261327 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258560 times.
273369 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3653
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247920 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247812 times.
261327 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3654
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246793 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 246031 times.
247812 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3655 )
3656 // The hammer should already be dealt with by subclasses (Walker etc.)
3657 {
3658
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3659 {
3660 // Weapons which shields protect against
3661 case wSword:
3662 case wWand:
3663
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3664 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3665
3666 [[fallthrough]];
3667 case wHookshot:
3668 case wHSHandle:
3669 case wBrang:
3670 6184 shieldCanBlock=true;
3671 6522 break;
3672
3673 case wBeam:
3674 case wRefBeam:
3675 // Mirror shielded enemies!
3676 #if 0
3677 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3678 {
3679 if(wpnId>wEnemyWeapons)
3680 return 0;
3681
3682 sfx(WAV_CHINK,pan(x));
3683 return 1;
3684 }
3685
3686 #endif
3687
3688 [[fallthrough]];
3689 case wRefRock:
3690 case wRefFireball:
3691 case wMagic:
3692 #if 0
3693 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3694 {
3695 sfx(WAV_CHINK,pan(x));
3696 return 3;
3697 }
3698
3699 #endif
3700
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3702 return 0;
3703
3704 [[fallthrough]];
3705 case wArrow:
3706 382 case wRefArrow:
3707 default:
3708 1870 shieldCanBlock=true;
3709 1870 break;
3710
3711 // Bombs
3712 case wSBomb:
3713 case wBomb:
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3715 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3716 {
3717 sfx(WAV_CHINK,pan(x));
3718 return 0;
3719 }
3720 else break;
3721
3722 // Weapons which ignore shields
3723 case wWhistle:
3724 case wHammer:
3725 153 break;
3726
3727 // Weapons which shouldn't be removed by shields
3728 case wLitBomb:
3729 case wLitSBomb:
3730 case wWind:
3731 case wPhantom:
3732 case wSSparkle:
3733 case wBait:
3734 864 return 0;
3735
3736 case wFire:
3737 case wRefFire:
3738 case wRefFire2:
3739 ;
3740 680 }
3741 8887 }
3742
3743
8/8
✓ Branch 0 taken 103219 times.
✓ Branch 1 taken 98026 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266198 switch(wpnId)
3744 {
3745 case wWhistle: //No longer completely ignore whistle weapons! -Z
3746 {
3747
3748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3749 {
3750 423 return 0; break;
3751 }
3752 else
3753 {
3754 w->power = power = itemsbuf[parent_item].misc5;
3755
3756 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3757
3758 if(def <= 0)
3759 {
3760 hp -= power;
3761 return def;
3762 }
3763 break;
3764 }
3765 break;
3766 }
3767
3768 case wPhantom:
3769 270 return 0;
3770
3771 case wLitBomb:
3772 case wLitSBomb:
3773 case wBait:
3774 case wWind:
3775 case wSSparkle:
3776 103219 return 0;
3777
3778 case wFSparkle:
3779
3780 // Only take sparkle damage if the sparkle's parent item is not
3781 // defended against.
3782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3783 {
3784 27402 int32_t p = 0;
3785 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3786
3787
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3788 {
3789 case itype_arrow:
3790 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3791
3792 break;
3793
3794 case itype_cbyrna:
3795 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3796
3797 break;
3798
3799 case itype_brang:
3800
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3801
3802 469 break;
3803
3804 default:
3805 return 0;
3806 }
3807 469 }
3808
3809 469 wpnId = wSword;
3810 469 power = game->get_hero_dmgmult()>>1;
3811 469 goto fsparkle;
3812 break;
3813
3814 case wBrang:
3815 {
3816 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3817 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3818 //preventing stunlock might be best, here. -Z
3819
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3820 19564 ret = def;
3821
3822 // Not hurt by 0-damage weapons
3823
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3824 {
3825 16380 stunclk=160;
3826
3827
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3828 {
3829
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3830 1311 goto hitclock;
3831 }
3832
3833 15069 break;
3834 }
3835
3836
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3837
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3838 else
3839 391 hp-=power;
3840
3841 3184 goto hitclock;
3842 }
3843
3844 case wHookshot:
3845 {
3846 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3847 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3848
3849
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3850 1773 ret = def;
3851
3852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3853
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3854 {
3855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3856 1625 stunclk=160;
3857
3858
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3859 {
3860
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3861 549 goto hitclock;
3862 }
3863
3864 1076 break;
3865 }
3866
3867
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3868 else
3869 45 hp-=power;
3870
3871 148 goto hitclock;
3872 }
3873 break;
3874
3875 case wHSHandle:
3876 {
3877
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3878 523 return 0;
3879
3880
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3882
3883 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3884
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3885
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3886 2177 return 0;
3887
3888 12102 power = game->get_hero_dmgmult();
3889 12571 }
3890
3891 fsparkle:
3892
3893 [[fallthrough]];
3894 default:
3895 // Work out the defenses!
3896 {
3897 99105 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3898
3899
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72539 times.
99105 if(def >= 0)
3900 26566 return def;
3901
2/2
✓ Branch 0 taken 72079 times.
✓ Branch 1 taken 460 times.
72539 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3902 460 ret = 0;
3903 }
3904
3905
2/2
✓ Branch 0 taken 72537 times.
✓ Branch 1 taken 2 times.
145078 if(!power)
3906 {
3907
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3908 2 hp-=1;
3909 else
3910 {
3911 // Don't make a long chain of 'stun' hits
3912 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3913 return 1;
3914
3915
3916 if(!switch_hooked)
3917 stunclk=160;
3918 break;
3919 }
3920 2 }
3921 72537 else hp-=power;
3922
3923 hitclock:
3924 77742 hclk=33;
3925
3926 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3927
2/2
✓ Branch 0 taken 34732 times.
✓ Branch 1 taken 43010 times.
77742 if((dir&2)==(w->dir&2))
3928 {
3929 43010 sclk=(w->dir<<8)+16;
3930 43010 }
3931 77742 }
3932
3933
5/6
✓ Branch 0 taken 74323 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21982 times.
✓ Branch 3 taken 71905 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21982 times.
93887 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3934 {
3935 21982 fading=fade_blue_poof;
3936 21982 }
3937
3938
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 5285 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93887 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3939 {
3940
1/2
✓ Branch 0 taken 7632 times.
✗ Branch 1 not taken.
7632 if( hitsfx > 0 ) //user-set hit sound.
3941 {
3942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7632 times.
7632 if (!dying) //don't play the hit sound on death! -Z
3943 7632 sfx(hitsfx, pan(x));
3944 7632 }
3945 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3946 7632 }
3947 else //2.50.2 or earlier
3948 {
3949 86255 sfx(WAV_EHIT, pan(x));
3950 86255 sfx(hitsfx, pan(x));
3951 }
3952
2/2
✓ Branch 0 taken 93858 times.
✓ Branch 1 taken 29 times.
93887 if(type==eeGUY)
3953 29 sfx(WAV_EDEAD, pan(x));
3954
3955 // Penetrating weapons
3956
4/4
✓ Branch 0 taken 92013 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85107 times.
✓ Branch 3 taken 8780 times.
93887 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3957 {
3958 8780 int32_t item=enemyHitWeapon;
3959
3960
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7168 times.
8780 if(wpnId==wArrow)
3961 {
3962 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3963
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3964 379 return 0;
3965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3966 //if(item<0)
3967 else
3968 1233 item=current_item_id(itype_arrow);
3969 1233 }
3970
3971 else
3972 {
3973
3974 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3975
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3976 return 0;
3977
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3979 else
3980 //if(item<0)
3981 7168 item=current_item_id(itype_sword);
3982 }
3983 8401 }
3984
3985 93508 return ret;
3986 269385 }
3987
3988 62723933 bool enemy::dont_draw() const
3989 {
3990
6/6
✓ Branch 0 taken 62259420 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 62188513 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 62084412 times.
62723933 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3991 639521 return true;
3992
3993
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 60712587 times.
62084412 if(flags&guy_invisible)
3994 1371825 return true;
3995
3996
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 60712155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
60712587 if(flags&guy_lens_only && !lensclk)
3997 return true;
3998
3999 60712587 return false;
4000 62723933 }
4001
4002 #define DRAW_NORMAL 2
4003 #define DRAW_CLOAKED 1
4004 #define DRAW_INVIS 0
4005 // base drawing function to be used by all derived classes instead of
4006 // sprite::draw()
4007 44971115 void enemy::draw(BITMAP *dest)
4008 {
4009 44971115 didScriptThisFrame = false; //Since there's no better place to put it
4010
6/6
✓ Branch 0 taken 44205983 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44123333 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43888452 times.
44971115 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4011 1082663 return;
4012
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41120787 times.
43888452 if(flags&guy_invisible)
4013 2767665 return;
4014
4015 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4016 // be cloaked if they have "invisible displays as cloaked" checked.
4017
4018 41120787 byte canSee = DRAW_NORMAL;
4019 //Enemy specific stuff
4020
2/2
✓ Branch 0 taken 41119623 times.
✓ Branch 1 taken 1164 times.
41120787 if ( editorflags & ENEMY_FLAG1 )
4021 {
4022 1164 canSee = DRAW_INVIS;
4023
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4024
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4025 {
4026 if (game->item[dmisc13])
4027 {
4028 canSee = DRAW_NORMAL;
4029 }
4030 //else if ( lensclk && getlensid.flags SHOWINVIS )
4031 //{
4032 //
4033 //}
4034 //else
4035 //{
4036 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4037 // //otherwisem invisible
4038 //}
4039 }
4040 1164 }
4041 //Room specific
4042 41120787 mapscr* scr = get_scr(screen_spawned);
4043
2/2
✓ Branch 0 taken 38949588 times.
✓ Branch 1 taken 2171199 times.
41120787 if (scr->flags3&fINVISROOM)
4044 {
4045
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4047 2171199 }
4048 //Lens check
4049
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41093250 times.
41120787 if (lensclk)
4050 {
4051
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4052 {
4053
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4054 432 }
4055 27537 }
4056 else
4057 {
4058
2/2
✓ Branch 0 taken 41019834 times.
✓ Branch 1 taken 73416 times.
41093250 if(flags&guy_lens_only)
4059 73416 canSee = DRAW_INVIS;
4060 }
4061
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41046207 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4062
3/4
✓ Branch 0 taken 40820203 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40820203 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4063
4064
2/2
✓ Branch 0 taken 41046207 times.
✓ Branch 1 taken 74580 times.
41120787 if (canSee == DRAW_INVIS)
4065 74580 return;
4066
4067
4/4
✓ Branch 0 taken 41043832 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41043825 times.
41046207 if(fallclk||drownclk)
4068 {
4069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4070 {
4071 sprite::drawcloaked(dest);
4072 }
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4074 {
4075 2382 sprite::draw(dest);
4076 2382 }
4077 2382 return;
4078 }
4079 41043825 int32_t cshold=cs;
4080
4081
2/2
✓ Branch 0 taken 904261 times.
✓ Branch 1 taken 40139564 times.
41043825 if(dying)
4082 {
4083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if(clk2>=19)
4084 {
4085 if(!(clk2&2))
4086 {
4087 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4088 if (canSee == DRAW_CLOAKED)
4089 {
4090 sprite::drawcloaked(dest);
4091 }
4092 else if (canSee == DRAW_NORMAL)
4093 {
4094 sprite::draw(dest);
4095 }
4096 }
4097 return;
4098 }
4099
4100 904261 flip = 0;
4101 904261 tile = wpnsbuf[spr_death].tile;
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if ( do_animation )
4103 {
4104 904261 int32_t offs = 0;
4105
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4106 {
4107
2/2
✓ Branch 0 taken 49521 times.
✓ Branch 1 taken 1628 times.
51149 if(clk2 > 2)
4108 {
4109 1628 spr_death_anim_clk=0;
4110 1628 clk2=1;
4111
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1614 times.
1628 if(hp > -1000)
4112 1614 death_sfx();
4113 1628 }
4114
4/4
✓ Branch 0 taken 38450 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38048 times.
51149 if(clk2==1 && spr_death_anim_clk>-1)
4115 {
4116 38048 ++clk2;
4117
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
38048 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4118
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38027 times.
38048 spr_death_anim_frm *= zc_max(1,txsz);
4119 38048 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4120
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37972 times.
38048 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4121
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38046 times.
✓ Branch 4 taken 36438 times.
✓ Branch 5 taken 1610 times.
38048 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4122 {
4123 1610 spr_death_anim_clk=-1;
4124 1610 clk2=1;
4125 1610 }
4126 38048 }
4127 51149 tile += spr_death_anim_frm;
4128 51149 }
4129
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4130 {
4131
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4132 315607 }
4133
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4134 {
4135 179336 offs = 1;
4136 179336 }
4137
4138
2/2
✓ Branch 0 taken 455768 times.
✓ Branch 1 taken 448493 times.
904261 if(offs)
4139 {
4140
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4141 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4142
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4143 448493 }
4144 904261 tile += offs;
4145 904261 }
4146
4147
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4148 555938 cs = wpnsbuf[spr_death].csets&15;
4149 else
4150 348323 cs = (((clk2+5)>>1)&3)+6;
4151 904261 }
4152
3/4
✓ Branch 0 taken 1204162 times.
✓ Branch 1 taken 38935402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1204162 times.
40139564 else if(hclk>0 && getCanFlicker())
4153 {
4154 1204162 cs = getFlashingCSet();
4155 1204162 }
4156 //draw every other frame for flickering enemies
4157
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40795794 times.
41043825 if (is_hitflickerframe(false))
4158 {
4159
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4160
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4161 {
4162 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4163 sprite_flicker_color = temp_flicker_color;
4164 sprite::draw(dest);
4165 }
4166 248031 }
4167 else
4168 {
4169
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40570632 times.
40795794 if (canSee == DRAW_CLOAKED)
4170 {
4171 225162 sprite::drawcloaked(dest);
4172 225162 }
4173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40570632 times.
40570632 else if (canSee == DRAW_NORMAL)
4174 {
4175
1/2
✓ Branch 0 taken 40570632 times.
✗ Branch 1 not taken.
40570632 if ( frozenclock < 0 )
4176 {
4177 if ( frozentile > 0 ) tile = frozentile;
4178 loadpalset(csBOSS,frozencset);
4179 }
4180 40570632 sprite::draw(dest);
4181 40570632 }
4182 }
4183 41043825 cs=cshold;
4184 44971115 }
4185
4186 //old zc bosses
4187 40943259 void enemy::drawzcboss(BITMAP *dest)
4188 {
4189 40943259 didScriptThisFrame = false; //Since there's no better place to put it
4190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40943259 times.
40943259 if(dont_draw())
4191 return;
4192
4193 40943259 int32_t cshold=cs;
4194
4195
2/2
✓ Branch 0 taken 784038 times.
✓ Branch 1 taken 40159221 times.
40943259 if(dying)
4196 {
4197
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 780078 times.
784038 if(clk2>=19)
4198 {
4199
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4200 1980 sprite::drawzcboss(dest);
4201
4202 3960 return;
4203 }
4204
4205 780078 flip = 0;
4206 780078 tile = wpnsbuf[spr_death].tile;
4207
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780078 times.
780078 if ( do_animation )
4209 {
4210
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4211 {
4212
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4213 {
4214 6 spr_death_anim_clk=0;
4215 6 clk2=1;
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4217 6 death_sfx();
4218 6 }
4219
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4220 {
4221 76 ++clk2;
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4224 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4227 {
4228 2 spr_death_anim_clk=-1;
4229 2 clk2=1;
4230 2 }
4231 76 }
4232 4516 tile += spr_death_anim_frm;
4233 4516 }
4234
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4235
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4236
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4237 165743 ++tile;
4238 780078 }
4239
4240
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4241 466974 cs = wpnsbuf[spr_death].csets&15;
4242 else
4243 313104 cs = (((clk2+5)>>1)&3)+6;
4244 780078 }
4245
2/2
✓ Branch 0 taken 38944531 times.
✓ Branch 1 taken 1214690 times.
40159221 else if(hclk>0)
4246 {
4247 1214690 cs = getFlashingCSet();
4248 1214690 }
4249
4250 40939299 mapscr* scr = get_scr(screen_spawned);
4251
4252
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38893680 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40946842 if((scr->flags3&fINVISROOM) &&
4253
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4255 7543 lensclk) && type!=eeGANON)
4256 {
4257 7543 sprite::drawcloaked(dest);
4258 7543 }
4259 else
4260 {
4261
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40908283 times.
40931756 if (is_hitflickerframe(true))
4262 {
4263
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4264
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4265 {
4266 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4267 sprite_flicker_color = temp_flicker_color;
4268 sprite::drawzcboss(dest);
4269 }
4270 23473 }
4271 else
4272 40908283 sprite::drawzcboss(dest);
4273 }
4274
4275 40939299 cs=cshold;
4276 40943259 }
4277
4278
4279 // similar to the overblock function--can do up to a 32x32 sprite
4280 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4281 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4282 {
4283 323235 int32_t thold=tile;
4284 323235 int32_t t1=tile;
4285 323235 int32_t t2=tile+20;
4286 323235 int32_t t3=tile+1;
4287 323235 int32_t t4=tile+21;
4288
4289
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4290 {
4291 case 1:
4292 enemy::drawzcboss(dest);
4293 break;
4294
4295 case 3:
4296 if(flip&2)
4297 zc_swap(t1,t2);
4298
4299 tile=t1;
4300 enemy::drawzcboss(dest);
4301 tile=t2;
4302 yofs+=16;
4303 enemy::drawzcboss(dest);
4304 yofs-=16;
4305 break;
4306
4307 case 5:
4308 t2=tile+1;
4309
4310 if(flip&1)
4311 zc_swap(t1,t2);
4312
4313 tile=t1;
4314 enemy::drawzcboss(dest);
4315 tile=t2;
4316 xofs+=16;
4317 enemy::drawzcboss(dest);
4318 xofs-=16;
4319 break;
4320
4321 case 15:
4322
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4323 {
4324 6756 zc_swap(t1,t3);
4325 6756 zc_swap(t2,t4);
4326 6756 }
4327
4328
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4329 {
4330 zc_swap(t1,t2);
4331 zc_swap(t3,t4);
4332 }
4333
4334 323235 tile=t1;
4335 323235 enemy::drawzcboss(dest);
4336 323235 tile=t2;
4337 323235 yofs+=16;
4338 323235 enemy::drawzcboss(dest);
4339 323235 yofs-=16;
4340 323235 tile=t3;
4341 323235 xofs+=16;
4342 323235 enemy::drawzcboss(dest);
4343 323235 tile=t4;
4344 323235 yofs+=16;
4345 323235 enemy::drawzcboss(dest);
4346 323235 xofs-=16;
4347 323235 yofs-=16;
4348 323235 break;
4349 }
4350
4351 323235 tile=thold;
4352 323235 }
4353
4354 21216849 bool enemy::can_drawshadow() const
4355 {
4356
4/4
✓ Branch 0 taken 19205503 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 18678585 times.
21216849 if(dont_draw() || isSideViewGravity())
4357 2538264 return false;
4358
4359
2/2
✓ Branch 0 taken 328358 times.
✓ Branch 1 taken 18350227 times.
18678585 if(dying)
4360 328358 return false;
4361
4362 18350227 mapscr* scr = get_scr(screen_spawned);
4363
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 16631978 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 18003217 times.
18350227 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4364 18350227 (darkroom))
4365 347010 return false;
4366
4367
5/6
✓ Branch 0 taken 16239718 times.
✓ Branch 1 taken 1763499 times.
✓ Branch 2 taken 16239718 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15640563 times.
✓ Branch 5 taken 599155 times.
18003217 if(z <= 0 && fakez <= 0 && enemycanfall(id, false))
4368 15640563 return false;
4369
4370
2/2
✓ Branch 0 taken 12687 times.
✓ Branch 1 taken 2349967 times.
2362654 if(shadow_overpit())
4371 12687 return false;
4372
4373 2349967 return true;
4374 21216849 }
4375 18009769 void enemy::drawshadow(BITMAP *dest, bool translucent)
4376 {
4377
2/2
✓ Branch 0 taken 16467007 times.
✓ Branch 1 taken 1542762 times.
18009769 if(!can_drawshadow())
4378 16467007 return;
4379
4/4
✓ Branch 0 taken 943607 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 692 times.
✓ Branch 3 taken 942915 times.
1542762 if(enemycanfall(id, false) && shadowtile == 0)
4380 692 shadowtile = wpnsbuf[spr_shadow].tile;
4381
4382 1542762 sprite::drawshadow(dest,translucent);
4383 18009769 }
4384
4385 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4386 {
4387 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4388
4389
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4390 {
4391 129181 xofs-=mx;
4392 129181 yofs-=my;
4393 129181 enemy::draw(sub);
4394 129181 xofs+=mx;
4395 129181 yofs+=my;
4396 129181 destroy_bitmap(sub);
4397 129181 }
4398 else
4399 enemy::draw(dest);
4400 129181 }
4401
4402 9 void enemy::init_size_flags()
4403 {
4404
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4405
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4406
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4407
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4409
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4410
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4411
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4412
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4413 {
4414 yofs = (int32_t)d->yofs;
4415 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4416 }
4417
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4418 9 }
4419
4420 // override hit detection to check for invicibility, stunned, etc
4421 112664439 bool enemy::hit()
4422 {
4423
4/4
✓ Branch 0 taken 111337172 times.
✓ Branch 1 taken 1327267 times.
✓ Branch 2 taken 109522516 times.
✓ Branch 3 taken 1814656 times.
112664439 if(dying || hclk>0) return false;
4424 109522516 return sprite::hit();
4425 112664439 }
4426 730351 bool enemy::hit(sprite *s)
4427 {
4428
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4429 713374 return sprite::hit(s);
4430 730351 }
4431
4432 44723304 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4433 {
4434
2/2
✓ Branch 0 taken 3973386 times.
✓ Branch 1 taken 40749918 times.
44723304 if(!hit()) return false;
4435 40749918 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4436 44723304 }
4437 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4438 {
4439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4440 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4441 78011 }
4442
4443 11190904 bool enemy::hit(weapon *w)
4444 {
4445
2/2
✓ Branch 0 taken 1196298 times.
✓ Branch 1 taken 9994606 times.
11190904 if(!hit()) return false;
4446
4447
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3347224 times.
9994606 if (replay_version_check(0, 14))
4448 {
4449
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4450 225051 return false;
4451 6422331 return sprite::hit(w);
4452 }
4453 3347224 return w->hit(this);
4454 11190904 }
4455
4456 38124564 bool enemy::can_pitfall(bool checkspawning)
4457 {
4458
4/4
✓ Branch 0 taken 36552358 times.
✓ Branch 1 taken 1572206 times.
✓ Branch 2 taken 36539384 times.
✓ Branch 3 taken 1585180 times.
38124564 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4459
2/2
✓ Branch 0 taken 29877757 times.
✓ Branch 1 taken 6661627 times.
36539384 switch(guysbuf[id&0xFFF].type)
4460 {
4461 case eeAQUA:
4462 case eeDIG:
4463 case eeDONGO:
4464 case eeFAIRY:
4465 case eeGANON:
4466 case eeGHOMA:
4467 case eeGLEEOK:
4468 case eeGUY:
4469 case eeLANM:
4470 case eeMANHAN:
4471 case eeMOLD:
4472 case eeNONE:
4473 case eePATRA:
4474 case eeZORA:
4475 6661627 return false; //Disallowed types
4476 default:
4477 29877757 return true;
4478 }
4479 38124564 }
4480 //Handle death
4481 38009335 void enemy::try_death(bool force_kill)
4482 {
4483
8/8
✓ Branch 0 taken 37952766 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37952755 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43653 times.
✓ Branch 5 taken 37909102 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43652 times.
38009335 if(!dying && (force_kill || (hp<=0 && !immortal)))
4484 {
4485 43663 std::vector<int32_t> &ev = FFCore.eventData;
4486 43663 ev.clear();
4487 43663 ev.push_back(10000);
4488 43663 ev.push_back(getUID());
4489
4490 43663 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4491 43663 bool isSaved = !ev[0];
4492 43663 ev.clear();
4493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43663 times.
43663 if(isSaved) return;
4494
4495
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43613 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43663 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4496 {
4497
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4498 {
4499
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4500 {
4501
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4502 {
4503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4504 {
4505 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4506 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4507 }
4508 else
4509 {
4510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4511 {
4512 items.spr(i)->x = x+(txsz-1)*8;
4513 items.spr(i)->y = y-2+(tysz-1)*8;
4514 }
4515 else
4516 {
4517 3 items.spr(i)->x = x;
4518 3 items.spr(i)->y = y - 2;
4519 }
4520 }
4521 3 items.spr(i)->z = z;
4522 3 items.spr(i)->fakez = fakez;
4523 3 }
4524 else
4525 {
4526 41 items.spr(i)->x = x;
4527 41 items.spr(i)->y = y - 2;
4528 }
4529 44 }
4530 51 }
4531 44 }
4532
4533 43663 dying=true;
4534
4535
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43631 times.
43663 if(fading==fade_flash_die)
4536 32 clk2=19+18*4;
4537 else
4538 {
4539 43631 clk2 = BSZ ? 15 : 19;
4540
4541
2/2
✓ Branch 0 taken 21062 times.
✓ Branch 1 taken 22569 times.
43631 if(fading!=fade_blue_poof)
4542 22569 fading=0;
4543 }
4544
4545
2/2
✓ Branch 0 taken 43613 times.
✓ Branch 1 taken 50 times.
43663 if(itemguy)
4546 {
4547 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4548 50 item_set=0;
4549 50 }
4550
6/6
✓ Branch 0 taken 42609 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33920 times.
✓ Branch 3 taken 8689 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32492 times.
43663 if (screen_spawned < 128 && count_enemy && !script_spawned)
4551 32492 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4552 43663 }
4553 38009335 }
4554
4555 // --==**==--
4556
4557 // Movement routines that can be used by derived classes as needed
4558
4559 // --==**==--
4560
4561 556554 void enemy::fix_coords(bool bound)
4562 {
4563
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4564
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if(moveflags & move_ignore_screenedge) bound = false;
4565
4566
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474874 times.
556554 if(bound)
4567 {
4568 474874 int w = world_w;
4569 474874 int h = world_h;
4570
4571
1/2
✓ Branch 0 taken 474874 times.
✗ Branch 1 not taken.
474874 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4572 {
4573
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4574
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4575 474874 }
4576 else
4577 {
4578 x=vbound(x, 0, w-16);
4579 y=vbound(y, 0, h-16);
4580 }
4581 474874 }
4582
4583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556554 times.
556554 if(!OUTOFBOUNDS(id, x, y))
4584 {
4585 556554 do_fix(x, 16, true);
4586
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555415 times.
556554 if(isSideViewGravity())
4587 1139 do_fix(y,8,true);
4588 555415 else do_fix(y,16,true);
4589 556554 }
4590 556554 }
4591 9176 bool enemy::cannotpenetrate()
4592 {
4593
4/4
✓ Branch 0 taken 8995 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8957 times.
9176 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4594 }
4595
4596 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4597 {
4598 bool ok;
4599 562 int32_t dx = 0, dy = 0;
4600 562 int32_t sv = 8;
4601
4602 //Why is this here??? Why is it needed???
4603 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4604
4605
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4606 {
4607 case 8:
4608 case up:
4609
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4610 return false;
4611
4612 69 dy = dy1-s;
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4615 69 break;
4616
4617 case 12:
4618 case down:
4619
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 51 dy = dy2+s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4624 51 break;
4625
4626 case 14:
4627 case left:
4628 47 dx = dx1-s;
4629 47 sv = ((isSideViewGravity())?7:8);
4630
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4632 47 break;
4633
4634 case 10:
4635 case right:
4636 85 dx = dx2+s;
4637 85 sv = ((isSideViewGravity())?7:8);
4638
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4639 85 break;
4640
4641 case 9:
4642 case r_up:
4643 94 dx = dx2+s;
4644 94 dy = dy1-s;
4645
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4647 94 break;
4648
4649 case 11:
4650 case r_down:
4651 78 dx = dx2+s;
4652 78 dx = dy2+s;
4653
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4655 78 break;
4656
4657 case 13:
4658 case l_down:
4659 57 dx = dx1-s;
4660 57 dy = dy2+s;
4661
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4663 57 break;
4664
4665 case 15:
4666 case l_up:
4667 81 dx = dx1-s;
4668 81 dy = dy1-s;
4669
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4671 81 break;
4672
4673 default:
4674 db=99;
4675 return true;
4676 }
4677
4678 562 return ok;
4679 562 }
4680
4681
4682
4683
4684 // returns true if next step is ok, false if there is something there
4685 7360028 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4686 {
4687 7360028 bool ok = false; //initialise the var, son't just declare it
4688 7360028 int32_t dx = 0, dy = 0;
4689 7360028 int32_t sv = 8;
4690 7360028 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4691 //Why is this here??? Why is it needed???
4692 7360028 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4695
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4696
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4697 7360028 bool offgrid = OFFGRID_ENEMY;
4698
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352737 times.
7360028 if(!offgrid)
4699 {
4700 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4701
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usehei<16)usehei=16;
4702
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usewid<16)usewid=16;
4703 7352737 }
4704
9/9
✓ Branch 0 taken 1331317 times.
✓ Branch 1 taken 1107763 times.
✓ Branch 2 taken 1227757 times.
✓ Branch 3 taken 1218339 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603869 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119676 times.
7360028 switch(ndir) //need to check every 8 pixels between two points
4705 {
4706 case 8:
4707 case up:
4708 {
4709
4/4
✓ Branch 0 taken 150808 times.
✓ Branch 1 taken 1180509 times.
✓ Branch 2 taken 150148 times.
✓ Branch 3 taken 660 times.
1331317 if(enemycanfall(id) && isSideViewGravity())
4710 660 return false;
4711
4712 1330657 dy = dy1-s;
4713
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330177 times.
1330657 special = (special==spw_clipbottomright)?spw_none:special;
4714 1330657 tries = usewid/(offgrid ? 8 : 16);
4715
4716
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 1331307 times.
2461744 for ( ; tries > 0; --tries )
4717 {
4718
2/2
✓ Branch 0 taken 197596 times.
✓ Branch 1 taken 1133711 times.
1331307 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4719 1331307 try_x += (offgrid ? 8 : 16);
4720
2/2
✓ Branch 0 taken 1131087 times.
✓ Branch 1 taken 200220 times.
1331307 if (!ok) break;
4721 1131087 }
4722
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 200220 times.
1330657 if(!ok) break;
4723
1/2
✓ Branch 0 taken 1130437 times.
✗ Branch 1 not taken.
1130437 if((usewid%16)>0) //Uneven width
4724 {
4725 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4726 }
4727 1130437 break;
4728 }
4729 case 12:
4730 case down:
4731 {
4732
4/4
✓ Branch 0 taken 180701 times.
✓ Branch 1 taken 927062 times.
✓ Branch 2 taken 179975 times.
✓ Branch 3 taken 726 times.
1107763 if(enemycanfall(id) && isSideViewGravity())
4733 726 return false;
4734
4735 1107037 dy = dy2+s;
4736 1107037 tries = usewid/(offgrid ? 8 : 16);
4737
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 1107821 times.
2008465 for ( ; tries > 0; --tries )
4738 {
4739
3/4
✓ Branch 0 taken 205645 times.
✓ Branch 1 taken 902176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902176 times.
1107821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4740 1107821 try_x += (offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 901428 times.
✓ Branch 1 taken 206393 times.
1107821 if (!ok) break;
4742 901428 }
4743
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 206393 times.
1107037 if(!ok) break;
4744
1/2
✓ Branch 0 taken 900644 times.
✗ Branch 1 not taken.
900644 if((usewid%16)>0) //Uneven width
4745 {
4746 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4747 }
4748 900644 break;
4749 }
4750 case 14:
4751 case left:
4752 {
4753 1227757 dx = dx1-s;
4754 1227757 sv = ((isSideViewGravity())?7:0);
4755
4/4
✓ Branch 0 taken 1227134 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225366 times.
1227757 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4756 1227757 tries = usehei/(offgrid ? 8 : 16);
4757
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 1228674 times.
2257217 for ( ; tries > 0; --tries )
4758 {
4759
2/2
✓ Branch 0 taken 198029 times.
✓ Branch 1 taken 1030645 times.
1228674 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4760 1228674 try_y += (offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1029460 times.
✓ Branch 1 taken 199214 times.
1228674 if (!ok) break;
4762 1029460 }
4763
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 199214 times.
1227757 if(!ok) break;
4764
1/2
✓ Branch 0 taken 1028543 times.
✗ Branch 1 not taken.
1028543 if((usehei%16)>0) //Uneven height
4765 {
4766 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4767 }
4768 1028543 break;
4769 }
4770 case 10:
4771 case right:
4772 {
4773 1218339 dx = dx2+s;
4774 1218339 sv = ((isSideViewGravity())?7:0);
4775 1218339 tries = usehei/(offgrid ? 8 : 16);
4776
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 1219233 times.
2249244 for ( ; tries > 0; --tries )
4777 {
4778
3/4
✓ Branch 0 taken 186973 times.
✓ Branch 1 taken 1032260 times.
✓ Branch 2 taken 1032260 times.
✗ Branch 3 not taken.
1219233 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4779 1219233 try_y += (offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1030905 times.
✓ Branch 1 taken 188328 times.
1219233 if (!ok) break;
4781 1030905 }
4782
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 188328 times.
1218339 if(!ok) break;
4783
1/2
✓ Branch 0 taken 1030011 times.
✗ Branch 1 not taken.
1030011 if((usehei%16)>0) //Uneven height
4784 {
4785 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4786 }
4787 1030011 break;
4788 }
4789 case 9:
4790 case r_up:
4791 {
4792 540601 dx = dx2+s;
4793 540601 dy = dy1-s;
4794 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4795 540601 sv = ((isSideViewGravity())?7:0);
4796
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4797 {
4798 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4799 540601 try_y = 0;
4800
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4801 {
4802
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4803
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4804 540601 try_y += (offgrid ? 8 : 16);
4805
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4806 523541 }
4807
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4809 {
4810 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4811 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4812 }
4813 523541 try_x += (offgrid ? 8 : 16);
4814 523541 }
4815
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4816
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4817 {
4818 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4819 try_y = 0;
4820 for ( ; tries_y > 0; --tries_y )
4821 {
4822 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4823 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4824 try_y += (offgrid ? 8 : 16);
4825 if (!ok) break;
4826 }
4827 if (!ok) break;
4828 if((usehei%16)>0) //Uneven height
4829 {
4830 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4831 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4832 }
4833 }
4834 523541 break;
4835 }
4836 case 11:
4837 case r_down:
4838 {
4839 642269 dx = dx2+s;
4840 642269 dx = dy2+s;
4841 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4842 //sv = ((isSideViewGravity())?7:0);
4843
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4844 {
4845 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4846 642269 try_y = 0;
4847
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4848 {
4849
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4850
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4851 642269 try_y += (offgrid ? 8 : 16);
4852
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4853 626871 }
4854
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4856 {
4857 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4858 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4859 }
4860 626871 try_x += (offgrid ? 8 : 16);
4861 626871 }
4862
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4863
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4864 {
4865 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4866 try_y = 0;
4867 for ( ; tries_y > 0; --tries_y )
4868 {
4869 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4870 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4871 try_y += (offgrid ? 8 : 16);
4872 if (!ok) break;
4873 }
4874 if (!ok) break;
4875 if((usehei%16)>0) //Uneven height
4876 {
4877 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4878 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4879 }
4880 }
4881 626871 break;
4882 }
4883 case 13:
4884 case l_down:
4885 {
4886 603869 dx = dx1-s;
4887 603869 dy = dy2+s;
4888 603869 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4889 //sv = ((isSideViewGravity())?7:0);
4890
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_x > 0; --tries_x )
4891 {
4892 603869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4893 603869 try_y = 0;
4894
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_y > 0; --tries_y )
4895 {
4896
4/4
✓ Branch 0 taken 591935 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587661 times.
✓ Branch 3 taken 4274 times.
1191530 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4897
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587093 times.
587661 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4898 603869 try_y += (offgrid ? 8 : 16);
4899
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4900 586793 }
4901
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586793 times.
586793 if((usehei%16)>0) //Uneven height
4903 {
4904 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4905 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4906 }
4907 586793 try_x += (offgrid ? 8 : 16);
4908 586793 }
4909
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if(!ok) break;
4910
1/2
✓ Branch 0 taken 586793 times.
✗ Branch 1 not taken.
586793 if((usewid%16)>0) //Uneven width
4911 {
4912 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4913 try_y = 0;
4914 for ( ; tries_y > 0; --tries_y )
4915 {
4916 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4917 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4918 try_y += (offgrid ? 8 : 16);
4919 if (!ok) break;
4920 }
4921 if (!ok) break;
4922 if((usehei%16)>0) //Uneven height
4923 {
4924 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4925 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4926 }
4927 }
4928 586793 break;
4929 }
4930 case 15:
4931 case l_up:
4932 {
4933 568437 dx = dx1-s;
4934 568437 dy = dy1-s;
4935 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4936 568437 sv = ((isSideViewGravity())?7:0);
4937
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4938 {
4939 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4940 568437 try_y = 0;
4941
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4942 {
4943
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4944
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4945 568437 try_y += (offgrid ? 8 : 16);
4946
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4947 552494 }
4948
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4950 {
4951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4953 }
4954 552494 try_x += (offgrid ? 8 : 16);
4955 552494 }
4956
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4957
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4958 {
4959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4960 try_y = 0;
4961 for ( ; tries_y > 0; --tries_y )
4962 {
4963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4965 try_y += (offgrid ? 8 : 16);
4966 if (!ok) break;
4967 }
4968 if (!ok) break;
4969 if((usehei%16)>0) //Uneven height
4970 {
4971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4973 }
4974 }
4975 552494 break;
4976 }
4977 default:
4978 119676 db=99;
4979 119676 return true;
4980 }
4981
4982 7238966 return ok;
4983 7360028 }
4984
4985
4986 4652348 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4987 {
4988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4990
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4991
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4992 4652348 --usewid;
4993 4652348 --usehei;
4994 4652348 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4995 }
4996
4997 1244902 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4998 {
4999 1244902 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5000
5001
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1238083 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244902 if(special==spw_clipright&&ndir==right)
5002 {
5003 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5004 1798 }
5005
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5006
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5007
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5008
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5009 1244902 --usewid;
5010 1244902 --usehei;
5011
2/2
✓ Branch 0 taken 717873 times.
✓ Branch 1 taken 527029 times.
1244902 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5012 }
5013
5014 136347 bool enemy::canmove(int32_t ndir, bool kb)
5015 {
5016 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5017 }
5018
5019 // 8-directional
5020 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5021 {
5022 562 int32_t ndir=0;
5023
5024 // can move straight, check if it wants to turn
5025
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5026 {
5027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5028 {
5029 int32_t w = Lwpns.idFirst(wBait);
5030
5031 if(w>=0)
5032 {
5033 int32_t bx = Lwpns.spr(w)->x;
5034 int32_t by = Lwpns.spr(w)->y;
5035
5036 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5037
5038 if(abs(int32_t(y)-by)>14)
5039 {
5040 if(ndir>0) // Already left or right
5041 {
5042 // Making the diagonal directions
5043 ndir += (by<y) ? 2 : 4;
5044 }
5045 else
5046 {
5047 ndir = (by<y) ? up : down;
5048 }
5049 }
5050
5051 if(canmove(ndir,special,false))
5052 {
5053 dir=ndir;
5054 return;
5055 }
5056 }
5057 }
5058
5059 // Homing added.
5060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5061 {
5062 ndir = lined_up(8,true);
5063
5064 if(ndir>=0 && canmove(ndir,special,false))
5065 {
5066 dir=ndir;
5067 }
5068
5069 return;
5070 }
5071
5072 549 int32_t r=zc_oldrand();
5073
5074
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5075 {
5076 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5077 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5078
5079
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5080 525 dir=ndir;
5081
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5082 19 dir=ndir2;
5083
5084
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5085 // due to numerous lost fractional components. -L
5086 {
5087 x.doFloor();
5088 y.doFloor();
5089 }
5090 549 }
5091
5092 549 return;
5093 }
5094
5095 // can't move straight, must turn
5096 13 int32_t i=0;
5097
5098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5099 {
5100 20 ndir=(zc_oldrand()&7)+8;
5101
5102
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5103 13 break;
5104 7 }
5105
5106
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5107 {
5108 for(ndir=8; ndir<16; ndir++)
5109 {
5110 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5111 goto ok;
5112 }
5113
5114 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5115 }
5116
5117 ok:
5118 13 dir=ndir;
5119 13 x.doFloor();
5120 13 y.doFloor();
5121 562 }
5122
5123 580728 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5124 {
5125 580728 int32_t ndir=0;
5126
5127 // can move straight, check if it wants to turn
5128
2/2
✓ Branch 0 taken 548065 times.
✓ Branch 1 taken 32663 times.
580728 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5129 {
5130
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547858 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548065 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5131 {
5132 101 int32_t i = Lwpns.idFirst(wBait);
5133
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5134 {
5135 weapon *w = (weapon*)Lwpns.spr(i);
5136 if (get_qr(qr_FIND_CLOSEST_BAIT))
5137 {
5138 int32_t currentrange;
5139 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5140 else currentrange = -1;
5141 int curid = i;
5142 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5143 for(; i<Lwpns.Count(); ++i)
5144 {
5145 weapon *lw = (weapon*)Lwpns.spr(i);
5146 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5147 {
5148 currentrange = distance(x, y, lw->x, lw->y);
5149 curid = i;
5150 }
5151 }
5152 i = curid;
5153 if (currentrange == -1) i = -1;
5154 }
5155 else
5156 {
5157 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5158 }
5159 if(i>=0)
5160 {
5161 int32_t bx = Lwpns.spr(i)->x;
5162 int32_t by = Lwpns.spr(i)->y;
5163
5164 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5165
5166 if(abs(int32_t(y)-by)>14)
5167 {
5168 if(ndir>0) // Already left or right
5169 {
5170 // Making the diagonal directions
5171 ndir += (by<y) ? 2 : 4;
5172 }
5173 else
5174 {
5175 ndir = (by<y) ? up : down;
5176 }
5177 }
5178 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5179 if(canmove(ndir,special,false))
5180 {
5181 dir=ndir;
5182 return;
5183 }
5184 }
5185 }
5186 101 }
5187
5188 // Homing added.
5189
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518439 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548065 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5190 {
5191 14216 ndir = lined_up(8,true);
5192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5193
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5194 {
5195 5852 dir=ndir;
5196 5852 }
5197
5198 14216 return;
5199 }
5200
5201 533849 int32_t r=zc_oldrand();
5202
5203
4/4
✓ Branch 0 taken 340048 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179767 times.
✓ Branch 3 taken 160281 times.
533849 if(newrate>0 && !(r%newrate))
5204 {
5205 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5206 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5207
5208
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5209 154477 dir=ndir;
5210
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5211 4947 dir=ndir2;
5212
5213
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5214 // due to numerous lost fractional components. -L
5215 {
5216 7326 x.doFloor();
5217 7326 y.doFloor();
5218 7326 }
5219 160281 }
5220
5221 533849 return;
5222 }
5223
5224 // can't move straight, must turn
5225 32663 int32_t i=0;
5226
5227 // TODO: speed this up!
5228
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5229 {
5230 61154 ndir=(zc_oldrand()&7)+8;
5231
5232
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5233 32593 break;
5234 28561 }
5235
5236
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5237 {
5238
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5239 {
5240
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5241 17 goto ok;
5242 444 }
5243
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5245 53 }
5246
5247 ok:
5248 32663 dir=ndir;
5249 32663 x.doFloor();
5250 32663 y.doFloor();
5251 580728 }
5252
5253 574253 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5254 {
5255 574253 newdir_8(newrate,newhoming,special,0,-8,15,15);
5256 574253 }
5257
5258 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5259 {
5260 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5261 562 }
5262
5263 // makes the enemy slide backwards when hit
5264 // sclk: first byte is clk, second byte is dir
5265 // makes the enemy slide backwards when hit
5266 // sclk: first byte is clk, second byte is dir
5267 15646054 int32_t enemy::slide()
5268 {
5269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15646054 times.
15646054 if(script_knockback_clk!=0) //scripted knockback
5270 {
5271 sclk = 0;
5272 return 1; //scripted knockback ran
5273 }
5274
5/6
✓ Branch 0 taken 102113 times.
✓ Branch 1 taken 15543941 times.
✓ Branch 2 taken 7857 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7857 times.
15646054 if(sclk==0 || (hp<=0 && !immortal))
5275 15551798 return 0;
5276
5277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5278 {
5279 sclk = 0;
5280 if(!OFFGRID_ENEMY)
5281 {
5282 //Fix to grid
5283 do_fix(x, 16, true);
5284 do_fix(y, 16, true);
5285 }
5286 return 0;
5287 }
5288
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5289 {
5290 2153 sclk=0;
5291 2153 return 0;
5292 }
5293
5294 92103 --sclk;
5295
5296
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5297 {
5298 case up:
5299 {
5300
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5301 {
5302 7 sclk=0;
5303 7 return 0;
5304 }
5305
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5306
5307 10357 break;
5308 }
5309 case down:
5310 {
5311
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5312 {
5313 2 sclk=0;
5314 2 return 0;
5315 }
5316
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5317
5318 12143 break;
5319 }
5320 case left:
5321 {
5322
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5323 {
5324 13 sclk=0;
5325 13 return 0;
5326 }
5327
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5328
5329 31483 break;
5330 }
5331 case right:
5332 {
5333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5334 {
5335 sclk=0;
5336 return 0;
5337 }
5338
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5339 35484 break;
5340 }
5341 }
5342
5343 91252 int32_t move = knockbackSpeed;
5344
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5345 {
5346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5347 91252 move -= thismove;
5348 91252 hitdir = (sclk>>8);
5349
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5350 {
5351 case up:
5352 10357 y-=thismove;
5353 10357 break;
5354
5355 case down:
5356 12143 y+=thismove;
5357 12143 break;
5358
5359 case left:
5360 31483 x-=thismove;
5361 31483 break;
5362
5363 case right:
5364 35484 x+=thismove;
5365 35484 break;
5366 }
5367
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5368 {
5369
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5370 {
5371 case up:
5372 case down:
5373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5374 y = 0;
5375
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5376 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5377 else
5378 1648 y = TRUNCATE_TILE(int32_t(y));
5379
5380 1973 break;
5381
5382 case left:
5383 case right:
5384
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5385 4 x = 0;
5386
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5387 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5388 else
5389 2069 x = TRUNCATE_TILE(int32_t(x));
5390
5391 2906 break;
5392 }
5393
5394 4883 sclk=0;
5395 4883 clk3=0;
5396 4883 break;
5397 }
5398 }
5399
5400
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5401 {
5402 //hitdir = -1;
5403 7363 sclk=0;
5404 7363 }
5405 91252 return 2;
5406 15646054 }
5407
5408 bool enemy::can_slide()
5409 {
5410 if(sclk==0 || (hp<=0 && !immortal))
5411 return false;
5412
5413 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5414 {
5415 return false;
5416 }
5417
5418 return true;
5419 }
5420
5421 bool enemy::fslide()
5422 {
5423 if(sclk==0 || (hp<=0 && !immortal))
5424 return false;
5425
5426 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5427 {
5428 sclk=0;
5429 return false;
5430 }
5431
5432 --sclk;
5433
5434 switch(sclk>>8)
5435 {
5436 case up:
5437 if(y<=16)
5438 {
5439 sclk=0;
5440 return false;
5441 }
5442
5443 break;
5444
5445 case down:
5446 if(y>=world_h-16)
5447 {
5448 sclk=0;
5449 return false;
5450 }
5451
5452 break;
5453
5454 case left:
5455 if(x<=16)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case right:
5464 if(x>=world_w-16)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471 }
5472 hitdir = (sclk>>8);
5473 switch(sclk>>8)
5474 {
5475 case up:
5476 y-=4;
5477 break;
5478
5479 case down:
5480 y+=4;
5481 break;
5482
5483 case left:
5484 x-=4;
5485 break;
5486
5487 case right:
5488 x+=4;
5489 break;
5490 }
5491
5492 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5493 {
5494 switch(sclk>>8)
5495 {
5496 case up:
5497 case down:
5498 if((int32_t(y)&15) > 7)
5499 y = TRUNCATE_TILE(int32_t(y)) + 16;
5500 else
5501 y = TRUNCATE_TILE(int32_t(y));
5502
5503 break;
5504
5505 case left:
5506 case right:
5507 if((int32_t(x)&15) > 7)
5508 x = TRUNCATE_TILE(int32_t(x)) + 16;
5509 else
5510 x = TRUNCATE_TILE(int32_t(x));
5511
5512 break;
5513 }
5514
5515 sclk=0;
5516 clk3=0;
5517 }
5518
5519 if((sclk&255)==0)
5520 sclk=0;
5521
5522 return true;
5523 }
5524
5525 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5526 {
5527 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5528 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5529 bool ret = sprite::knockback(time, dir, speed);
5530 if(ret) sclk = 0; //kill engine knockback if interrupted
5531 //! Perhaps also set hitdir here, if needed for timing? -Z
5532 return ret;
5533 }
5534
5535 38009324 bool enemy::runKnockback()
5536 {
5537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if((script_knockback_clk&0xFF)==0)
5538 {
5539 38009324 script_knockback_clk = 0;
5540 38009324 return false;
5541 }
5542 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5543 {
5544 return false;
5545 }
5546 int32_t move = script_knockback_speed;
5547 int32_t kb_dir = script_knockback_clk>>8;
5548 --script_knockback_clk;
5549
5550 while(move>0)
5551 {
5552 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5553 move -= thismove;
5554 hitdir = kb_dir;
5555 switch(kb_dir)
5556 {
5557 case r_up:
5558 case l_up:
5559 case up:
5560 y-=thismove;
5561 break;
5562
5563 case r_down:
5564 case l_down:
5565 case down:
5566 y+=thismove;
5567 break;
5568 }
5569 switch(kb_dir)
5570 {
5571 case l_up:
5572 case l_down:
5573 case left:
5574 x-=thismove;
5575 break;
5576
5577 case r_up:
5578 case r_down:
5579 case right:
5580 x+=thismove;
5581 break;
5582 }
5583 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5584 {
5585 if(!canmove(kb_dir,(zfix)0,0,true))
5586 {
5587 script_knockback_clk=0;
5588 clk3=0;
5589 //Fix to grid
5590 switch(kb_dir)
5591 {
5592 case up:
5593 case down:
5594 break;
5595 default:
5596 if(x < 0)
5597 x = 0;
5598 else if((int32_t(x)&15) > 7)
5599 x = TRUNCATE_TILE(int32_t(x)) + 16;
5600 else
5601 x = TRUNCATE_TILE(int32_t(x));
5602 break;
5603 }
5604 switch(kb_dir)
5605 {
5606 case left:
5607 case right:
5608 break;
5609 default:
5610 if(y < 0)
5611 y = 0;
5612 else if((int32_t(y)&15) > 7)
5613 y = TRUNCATE_TILE(int32_t(y)) + 16;
5614 else
5615 y = TRUNCATE_TILE(int32_t(y));
5616 break;
5617 }
5618 break;
5619 }
5620 }
5621 else
5622 {
5623 if(!scr_canplace(x,y,0,true))
5624 {
5625 script_knockback_clk=0;
5626 clk3=0;
5627 //Fix to grid
5628 if (OFFGRID_ENEMY)
5629 {
5630 switch(kb_dir)
5631 {
5632 case up:
5633 case down:
5634 break;
5635 default:
5636 if(x < 0)
5637 x = 0;
5638 else if((int32_t(x)&7) > 3)
5639 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5640 else
5641 x = TRUNCATE_HALF_TILE(int32_t(x));
5642 break;
5643 }
5644 switch(kb_dir)
5645 {
5646 case left:
5647 case right:
5648 break;
5649 default:
5650 if(y < 0)
5651 y = 0;
5652 else if((int32_t(y)&7) > 3)
5653 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5654 else
5655 y = TRUNCATE_HALF_TILE(int32_t(y));
5656 break;
5657 }
5658 }
5659 else
5660 {
5661 switch(kb_dir)
5662 {
5663 case up:
5664 case down:
5665 break;
5666 default:
5667 if(x < 0)
5668 x = 0;
5669 else if((int32_t(x)&15) > 7)
5670 x = TRUNCATE_TILE(int32_t(x)) + 16;
5671 else
5672 x = TRUNCATE_TILE(int32_t(x));
5673 break;
5674 }
5675 switch(kb_dir)
5676 {
5677 case left:
5678 case right:
5679 break;
5680 default:
5681 if(y < 0)
5682 y = 0;
5683 else if((int32_t(y)&15) > 7)
5684 y = TRUNCATE_TILE(int32_t(y)) + 16;
5685 else
5686 y = TRUNCATE_TILE(int32_t(y));
5687 break;
5688 }
5689 }
5690 break;
5691 }
5692
5693 }
5694 }
5695 return true;
5696 38009324 }
5697 // changes enemy's direction, checking restrictions
5698 // rate: 0 = no random changes, 16 = always random change
5699 // homing: 0 = none, 256 = always
5700 // grumble 0 = none, 4 = strongest appetite
5701 521075 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5702 {
5703 521075 int32_t ndir=-1;
5704
5705
4/4
✓ Branch 0 taken 110060 times.
✓ Branch 1 taken 411015 times.
✓ Branch 2 taken 37882 times.
✓ Branch 3 taken 72178 times.
521075 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5706 {
5707 72178 int32_t i = Lwpns.idFirst(wBait);
5708
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5709 {
5710 weapon *w = (weapon*)Lwpns.spr(i);
5711 if (get_qr(qr_FIND_CLOSEST_BAIT))
5712 {
5713 int32_t currentrange;
5714 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5715 else currentrange = -1;
5716 int curid = i;
5717 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5718 for(; i<Lwpns.Count(); ++i)
5719 {
5720 weapon *lw = (weapon*)Lwpns.spr(i);
5721 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5722 {
5723 currentrange = distance(x, y, lw->x, lw->y);
5724 curid = i;
5725 }
5726 }
5727 i = curid;
5728 if (currentrange == -1) i = -1;
5729 }
5730 else
5731 {
5732 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5733 }
5734 if (i >= 0)
5735 {
5736 int32_t bx = Lwpns.spr(i)->x;
5737 int32_t by = Lwpns.spr(i)->y;
5738
5739 if(abs(int32_t(y)-by)>14)
5740 {
5741 ndir = (by<y) ? up : down;
5742 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5743 if(canmove(ndir,special,false))
5744 {
5745 dir=ndir;
5746 return;
5747 }
5748 }
5749
5750 ndir = (bx<x) ? left : right;
5751 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5752 if(canmove(ndir,special,false))
5753 {
5754 dir=ndir;
5755 return;
5756 }
5757 }
5758 }
5759 72178 }
5760
5761
2/2
✓ Branch 0 taken 352951 times.
✓ Branch 1 taken 168124 times.
521075 if((zc_oldrand()&255)<abs(newhoming))
5762 {
5763 168124 ndir = lined_up(8,false);
5764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168124 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5765
4/4
✓ Branch 0 taken 45390 times.
✓ Branch 1 taken 122734 times.
✓ Branch 2 taken 5720 times.
✓ Branch 3 taken 39670 times.
168124 if(ndir>=0 && canmove(ndir,special,false))
5766 {
5767 39670 dir=ndir;
5768 39670 return;
5769 }
5770 128454 }
5771
5772 481405 int32_t i=0;
5773
5774
2/2
✓ Branch 0 taken 3340 times.
✓ Branch 1 taken 1181128 times.
1184468 for(; i<32; i++)
5775 {
5776 1181128 int32_t r=zc_oldrand();
5777
5778
2/2
✓ Branch 0 taken 345129 times.
✓ Branch 1 taken 835999 times.
1181128 if((r&15)<newrate)
5779 345129 ndir=(r>>4)&3;
5780 else
5781 835999 ndir=dir;
5782
5783
2/2
✓ Branch 0 taken 703063 times.
✓ Branch 1 taken 478065 times.
1181128 if(canmove(ndir,special,false))
5784 478065 break;
5785 703063 }
5786
5787
2/2
✓ Branch 0 taken 478065 times.
✓ Branch 1 taken 3340 times.
482163 if(i==32)
5788 {
5789
2/2
✓ Branch 0 taken 8939 times.
✓ Branch 1 taken 758 times.
9697 for(ndir=0; ndir<4; ndir++)
5790 {
5791
2/2
✓ Branch 0 taken 6357 times.
✓ Branch 1 taken 2582 times.
8939 if(canmove(ndir,special,false))
5792 2582 goto ok;
5793 6357 }
5794
5795
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 698 times.
758 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5796 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5797 758 }
5798
5799 ok:
5800 481405 dir = ndir;
5801 521075 }
5802
5803 2682 void enemy::newdir()
5804 {
5805 2682 newdir(4,0,spw_none);
5806 2682 }
5807
5808 zfix enemy::distance_left()
5809 {
5810 int32_t a2=x.getInt();
5811 int32_t b2=y.getInt();
5812
5813 switch(dir)
5814 {
5815 case up:
5816 return (zfix)(b2&0xF);
5817
5818 case down:
5819 return (zfix)(16-(b2&0xF));
5820
5821 case left:
5822 return (zfix)(a2&0xF);
5823
5824 case right:
5825 return (zfix)(16-(a2&0xF));
5826 }
5827
5828 return (zfix)0;
5829 }
5830
5831 // keeps walking around
5832 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5833 {
5834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5835 return;
5836
5837
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5838 8261 return;
5839
5840
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5841 {
5842 26115 fix_coords(true);
5843 26115 newdir(newrate,newhoming,special);
5844
5845
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5846 clk3=0;
5847 else
5848 26115 clk3=int32_t(16.0/step);
5849 26115 }
5850
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5851 {
5852 45 dir^=1;
5853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5854 else clk3=32767;
5855 45 }
5856
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5858 383173 move(step);
5859 391434 }
5860
5861 void enemy::constant_walk()
5862 {
5863 constant_walk(4,0,spw_none);
5864 }
5865
5866 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5867 {
5868 35220 return (newy<<8)+newx;
5869 }
5870
5871 // for variable step rates
5872 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5873 {
5874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5875 return;
5876
5877
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5878 55444 return;
5879
5880 418370 zfix dx = (zfix)0;
5881 418370 zfix dy = (zfix)0;
5882
5883
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5884 {
5885 case 8:
5886 case up:
5887 93441 dy-=step;
5888 93441 break;
5889
5890 case 12:
5891 case down:
5892 97752 dy+=step;
5893 97752 break;
5894
5895 case 14:
5896 case left:
5897 111603 dx-=step;
5898 111603 break;
5899
5900 case 10:
5901 case right:
5902 113743 dx+=step;
5903 113743 break;
5904
5905 case 15:
5906 case l_up:
5907 dx-=step;
5908 dy-=step;
5909 break;
5910
5911 case 9:
5912 case r_up:
5913 dx+=step;
5914 dy-=step;
5915 break;
5916
5917 case 13:
5918 case l_down:
5919 dx-=step;
5920 dy+=step;
5921 break;
5922
5923 case 11:
5924 case r_down:
5925 dx+=step;
5926 dy+=step;
5927 break;
5928 }
5929
5930
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5931 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5932 {
5933 12443 fix_coords();
5934 12443 newdir(newrate,newhoming,special);
5935 12443 clk3=pos(x,y);
5936 12443 }
5937
5938 418370 move(step);
5939 473814 }
5940
5941 // pauses for a while after it makes a complete move (to a new square)
5942 12334139 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5943 {
5944
4/4
✓ Branch 0 taken 79892 times.
✓ Branch 1 taken 12254247 times.
✓ Branch 2 taken 67060 times.
✓ Branch 3 taken 12832 times.
12334139 if(sclk && clk2)
5945 {
5946 12832 clk3=0;
5947 12832 }
5948
5949
11/14
✓ Branch 0 taken 12261115 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12261115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12261115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11793947 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11656198 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11651662 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11651662 times.
12334139 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5950 {
5951 682477 return;
5952 }
5953
5954
2/2
✓ Branch 0 taken 2132955 times.
✓ Branch 1 taken 9518707 times.
11651662 if(clk2>0)
5955 {
5956 2132955 --clk2;
5957 2132955 return;
5958 }
5959
5960
2/2
✓ Branch 0 taken 411244 times.
✓ Branch 1 taken 9107463 times.
9518707 if(clk3<=0)
5961 {
5962 411244 fix_coords(true);
5963 411244 newdir(newrate,newhoming,special);
5964 411244 clk3=int32_t(16.0/step);
5965
2/2
✓ Branch 0 taken 411047 times.
✓ Branch 1 taken 197 times.
411244 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411244 times.
411244 if(clk2<0)
5967 {
5968 clk2=0;
5969 }
5970
2/2
✓ Branch 0 taken 54771 times.
✓ Branch 1 taken 356473 times.
411244 else if((zc_oldrand()&15)<newhrate)
5971 {
5972 54771 clk2=haltcnt;
5973 54771 return;
5974 }
5975 356473 }
5976
2/2
✓ Branch 0 taken 9104303 times.
✓ Branch 1 taken 3160 times.
9107463 else if(scored)
5977 {
5978 3160 dir^=1;
5979
5980
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3155 times.
3160 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5981 5 else clk3=32767;
5982 3160 }
5983
5984
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9386997 times.
9463936 if (step != 0) --clk3;
5985 9463936 move(step);
5986 12334139 }
5987
5988 // 8-directional movement, aligns to 8 pixels
5989 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5990 {
5991 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5992 return;
5993
5994 if(clk3<=0)
5995 {
5996 newdir_8(newrate,newhoming,special);
5997 clk3=int32_t(8.0/step);
5998 if (step == 0) clk3 = 32767;
5999 }
6000
6001 if (step != 0) --clk3;
6002 move(step);
6003 }
6004 // 8-directional movement, aligns to 8 pixels
6005 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6006 {
6007
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6008 return;
6009
6010
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6011 {
6012 16235 newdir_8(newrate,newhoming,special);
6013 16235 clk3=int32_t(8.0/step);
6014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6015 16235 }
6016
6017
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6018 242393 move(step);
6019 242393 }
6020
6021 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6022 {
6023 if(clk<0 || dying || stunclk || watch || frozenclock)
6024 return;
6025
6026 if(!canmove(dir,step,special,false))
6027 clk3=0;
6028
6029 if(clk2>0)
6030 {
6031 --clk2;
6032 return;
6033 }
6034
6035 if(clk3<=0)
6036 {
6037 newdir_8(newrate,newhoming,special);
6038 clk3=newclk;
6039
6040 if(clk2<0)
6041 {
6042 clk2=0;
6043 }
6044 else if((zc_oldrand()&15)<newhrate)
6045 {
6046 newdir_8(newrate,newhoming,special);
6047 clk2=haltcnt;
6048 return;
6049 }
6050 }
6051
6052 --clk3;
6053 move(step);
6054 }
6055
6056 // 8-directional movement, no alignment
6057 4721045 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6058 {
6059
9/12
✓ Branch 0 taken 4511760 times.
✓ Branch 1 taken 209285 times.
✓ Branch 2 taken 4511760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485139 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474092 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474092 times.
4721045 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6060 246953 return;
6061
6062
2/2
✓ Branch 0 taken 4443604 times.
✓ Branch 1 taken 30488 times.
4474092 if(!canmove(dir,step,special,false))
6063 30488 clk3=0;
6064
6065
2/2
✓ Branch 0 taken 3916074 times.
✓ Branch 1 taken 558018 times.
4474092 if(clk3<=0)
6066 {
6067 558018 newdir_8(newrate,newhoming,special);
6068 558018 clk3=newclk;
6069 558018 }
6070
6071 4474092 --clk3;
6072 4474092 move(step);
6073 4721045 }
6074
6075 // same as above but with variable enemy size
6076 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6077 {
6078
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6079 1247 return;
6080
6081
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6082 1334 clk3=0;
6083
6084
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6085 {
6086 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6087 6475 clk3=newclk;
6088 6475 }
6089
6090 93316 --clk3;
6091 93316 move(step);
6092 94563 }
6093
6094 // the variable speed floater movement
6095 // ms is max speed
6096 // ss is step speed
6097 // s is step count
6098 // p is pause count
6099 // g is graduality :)
6100 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6101 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6102 {
6103 4019514 ++clk2;
6104 4019514 bool over_pit = overpit();
6105
6106
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6107
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6108 {
6109 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6110 //! if the conditions prevent it, we jump back to case 2.
6111 case 0: // paused
6112
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6113 {
6114 1451 movestatus=1;
6115 1451 clk2=0;
6116 1451 }
6117
6118 56650 break;
6119
6120 case 1: // speeding up
6121
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6122 {
6123
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6124 {
6125
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6126 101600 step+=ss;
6127 1575074 }
6128 else
6129 {
6130 11306 movestatus=2;
6131 11306 clk2=0;
6132 }
6133 1586380 }
6134 else
6135 {
6136 if(step < ms)
6137 {
6138 if(!((clk2-1)%g))
6139 {
6140 step+=ss;
6141 if (step >= ms) step = ms;
6142 }
6143 }
6144 else
6145 {
6146 step = ms;
6147 movestatus=2;
6148 clk2=0;
6149 }
6150 }
6151
6152 1586380 break;
6153
6154 case 2: // normal
6155 2243416 step=ms;
6156
6157
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6158 {
6159
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6160 else step=ms;
6161 2250 movestatus=3;
6162 2250 clk2=0;
6163 2250 }
6164
6165 2243416 break;
6166
6167 case 3: // slowing down
6168
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6169 {
6170
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6171 {
6172 { //don't slow down over pits
6173
6174
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6175 {
6176
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(dmisc1)
6177 {
6178 step=ms;
6179 }
6180 267 }
6181 else //can slow down
6182 {
6183
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6184 7720 step-=ss;
6185 }
6186 }
6187
6188
6189 131387 }
6190 else
6191 {
6192 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6193 //this doesn't help keese, as they have a z of 0.
6194 //they always nee to run this check.
6195 {
6196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6197 {
6198 --clk2; //if over a pit, don't land, and revert clock change
6199 }
6200 else //can land safely
6201 {
6202 1681 movestatus=0;
6203
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6204 1115 step=0;
6205 1681 clk2=0;
6206 }
6207 }
6208
6209 }
6210 133068 }
6211 else
6212 {
6213 if(step > 0)
6214 {
6215 if(over_pit)
6216 {
6217 if(dmisc1)
6218 {
6219 step=ms;
6220 }
6221 }
6222 else //can slow down
6223 {
6224 if(!(clk2%g))
6225 step-=ss;
6226 }
6227 }
6228 else
6229 {
6230 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6231 //this doesn't help keese, as they have a z of 0.
6232 //they always nee to run this check.
6233 if(over_pit)
6234 {
6235 step+=ss; //if over a pit, don't land, and revert clock change
6236 }
6237 else //can land safely
6238 {
6239 movestatus=0;
6240 step=0;
6241 clk2=0;
6242 }
6243 }
6244 }
6245
6246 133068 break;
6247 }
6248
6249
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6250 4019514 }
6251
6252 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6253 {
6254 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6255 }
6256
6257 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6258 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6259 927949 int32_t enemy::lined_up(int32_t range, bool dir8)
6260 {
6261 927949 int32_t lx = Hero.getX();
6262 927949 int32_t ly = Hero.getY();
6263
6264
2/2
✓ Branch 0 taken 38914 times.
✓ Branch 1 taken 889035 times.
927949 if(abs(lx-int32_t(x))<=range)
6265 {
6266
2/2
✓ Branch 0 taken 16351 times.
✓ Branch 1 taken 22563 times.
38914 if(ly<y)
6267 {
6268 16351 return up;
6269 }
6270
6271 22563 return down;
6272 }
6273
6274
2/2
✓ Branch 0 taken 56361 times.
✓ Branch 1 taken 832674 times.
889035 if(abs(ly-int32_t(y))<=range)
6275 {
6276
2/2
✓ Branch 0 taken 30301 times.
✓ Branch 1 taken 26060 times.
56361 if(lx<x)
6277 {
6278 30301 return left;
6279 }
6280
6281 26060 return right;
6282 }
6283
6284
2/2
✓ Branch 0 taken 160084 times.
✓ Branch 1 taken 672590 times.
832674 if(dir8)
6285 {
6286
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6287 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6288 {
6289
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6290 {
6291
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6292 {
6293 56676 return l_up;
6294 }
6295 else
6296 {
6297 49404 return r_up;
6298 }
6299 }
6300 else
6301 {
6302
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6303 {
6304 71072 return l_down;
6305 }
6306 else
6307 {
6308 76696 return r_down;
6309 }
6310 }
6311 }
6312 418742 }
6313
6314 578826 return -1;
6315 927949 }
6316
6317 // returns true if Hero is within 'range' pixels of the enemy
6318 27884 bool enemy::HeroInRange(int32_t range)
6319 {
6320 27884 int32_t lx = Hero.getX();
6321 27884 int32_t ly = Hero.getY();
6322
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6323 }
6324
6325 // place the enemy in line with Hero (red wizzrobes)
6326 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6327 {
6328
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6329
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6330 4899 int32_t pos2=zc_oldrand()%23;
6331 4899 int32_t tried=0;
6332 4899 bool last_resort,placed=false;
6333
6334
6335 4899 do
6336 {
6337
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6338 {
6339 4460 x=(pos2<<4)+16;
6340 4460 y=ly;
6341 4460 }
6342 else
6343 {
6344 3127 x=lx;
6345 3127 y=((pos2-14)<<4)+16;
6346 }
6347
6348 // Don't commit to a last resort if position is out of bounds.
6349
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6350
6351
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4930 times.
✓ Branch 3 taken 1429 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6352 {
6353 // Red Wizzrobes should be able to appear on water, but not other
6354 // solid combos; however, they could appear on solid combos in 2.10,
6355 // and some quests depend on that.
6356
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6269 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4899 times.
8610 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6357 8610 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6358 4899 placed=true;
6359 8610 }
6360
6361
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7367 if(!placed && tried>=22 && last_resort)
6362 {
6363 placed=true;
6364 }
6365
6366 7367 ++tried;
6367 7367 pos2=(pos2+3)%23;
6368
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4679 times.
7367 }
6369 7367 while(!placed);
6370
6371
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 1808 times.
4679 if(y==ly)
6372 2871 dir=(x<lx)?right:left;
6373 else
6374 1808 dir=(y<ly)?down:up;
6375
6376 4679 clk2=tried;
6377 4679 }
6378
6379 20335203 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6380 {
6381 20335203 int32_t t = o_tile;
6382 20335203 int32_t b = o_tile;
6383
6384 // Darknuts, but also Wizzrobes and Wallmasters
6385
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877881 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20335203 switch(type)
6386 {
6387 case eeWALK:
6388
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372474 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877881 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6389 {
6390 367468 tile=s_tile;
6391 367468 t=s_tile;
6392 367468 b=s_tile;
6393 367468 }
6394
6395 10877881 break;
6396
6397 case eeTRAP:
6398
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6399 {
6400 193566 tile=s_tile;
6401 193566 t=s_tile;
6402 193566 b=s_tile;
6403 193566 }
6404
6405 1039770 break;
6406
6407 case eeSPINTILE:
6408 if(misc>=96 && do_animation)
6409 {
6410 tile=o_tile+frames*ndir;
6411 t=tile;
6412 }
6413
6414 break;
6415 }
6416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335203 times.
20335203 if ( do_animation )
6417 {
6418
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20138161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19871030 times.
20335203 if(ndir!=0) switch(frames)
6419 {
6420 case 2:
6421 267131 tiledir_small(dir,ndir==4);
6422 267131 break;
6423
6424 case 3:
6425 tiledir_three(dir);
6426 break;
6427
6428 case 4:
6429 19871030 tiledir(dir,ndir==4);
6430 19871030 break;
6431 20138161 }
6432
6433
2/2
✓ Branch 0 taken 10877881 times.
✓ Branch 1 taken 9457322 times.
20335203 if(type==eeWALK)
6434
6/6
✓ Branch 0 taken 10816559 times.
✓ Branch 1 taken 61322 times.
✓ Branch 2 taken 8211621 times.
✓ Branch 3 taken 2666260 times.
✓ Branch 4 taken 2650448 times.
✓ Branch 5 taken 15812 times.
10877881 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6435 else
6436 9457322 tile+=f4;
6437 20335203 }
6438 20335203 return b;
6439 }
6440
6441 void enemy::tiledir_three(int32_t ndir)
6442 {
6443 if ( !do_animation ) return;
6444 flip=0;
6445
6446 switch(ndir)
6447 {
6448 case right:
6449 tile+=3;
6450 [[fallthrough]];
6451
6452 case left:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case down:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case up:
6461 break;
6462 }
6463 }
6464
6465 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6466 {
6467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6468 267131 flip=0;
6469
6470
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6471 {
6472 case 8:
6473 case up:
6474 53829 break;
6475
6476 case 12:
6477 case down:
6478 54679 tile+=2;
6479 54679 break;
6480
6481 case 14:
6482 case left:
6483 67727 tile+=4;
6484 67727 break;
6485
6486 case 10:
6487 case right:
6488 71182 tile+=6;
6489 71182 break;
6490
6491 case 9:
6492 case r_up:
6493
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6494 5706 break;
6495
6496 tile+=10;
6497 break;
6498
6499 case 11:
6500 case r_down:
6501
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6502 5154 tile+=2;
6503 else
6504 tile+=14;
6505
6506 5154 break;
6507
6508 case 13:
6509 case l_down:
6510
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6511 4872 tile+=2;
6512 else
6513 tile+=12;
6514
6515 4872 break;
6516
6517 case 15:
6518 case l_up:
6519
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6520 3982 break;
6521
6522 tile+=8;
6523 break;
6524
6525 default:
6526 //dir=(zc_oldrand()*100)%8;
6527 //tiledir_small(dir);
6528 // flip=zc_oldrand()&3;
6529 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6530 break;
6531 }
6532 267131 }
6533
6534 23203778 void enemy::tiledir(int32_t ndir, bool fourdir)
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203778 times.
23203778 if ( !do_animation ) return;
6537 23203778 flip=0;
6538
6539
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163442 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 67162 times.
23203778 switch(ndir)
6540 {
6541 case 8:
6542 case up:
6543 4509460 break;
6544
6545 case 12:
6546 case down:
6547 4163442 tile+=4;
6548 4163442 break;
6549
6550 case 14:
6551 case left:
6552 5444983 tile+=8;
6553 5444983 break;
6554
6555 case 10:
6556 case right:
6557 5198041 tile+=12;
6558 5198041 break;
6559
6560 case 9:
6561 case r_up:
6562
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6563 89257 break;
6564 else
6565 744883 tile+=24;
6566
6567 744883 break;
6568
6569 case 11:
6570 case r_down:
6571
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6572 102657 tile+=4;
6573 else
6574 924955 tile+=32;
6575
6576 1027612 break;
6577
6578 case 13:
6579 case l_down:
6580
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6581 106171 tile+=4;
6582 else
6583 1000286 tile+=28;
6584
6585 1106457 break;
6586
6587 case 15:
6588 case l_up:
6589
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6590 82882 break;
6591 else
6592 769599 tile+=20;
6593
6594 769599 break;
6595
6596 default:
6597 //dir=(zc_oldrand()*100)%8;
6598 //tiledir(dir);
6599 // flip=zc_oldrand()&3;
6600 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6601 67162 break;
6602 }
6603 23203778 }
6604
6605 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6606 {
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6608 3868 flip=0;
6609
6610
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6611 {
6612 case 8:
6613 case up:
6614 297 break;
6615
6616 case 12:
6617 case down:
6618 tile+=8;
6619 break;
6620
6621 case 14:
6622 case left:
6623 195 tile+=40;
6624 195 break;
6625
6626 case 10:
6627 case right:
6628 179 tile+=48;
6629 179 break;
6630
6631 case 9:
6632 case r_up:
6633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6634 break;
6635
6636 306 tile+=88;
6637 306 break;
6638
6639 case 11:
6640 case r_down:
6641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6642 tile+=8;
6643 else
6644 1235 tile+=128;
6645
6646 1235 break;
6647
6648 case 13:
6649 case l_down:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6651 tile+=8;
6652 else
6653 1324 tile+=120;
6654
6655 1324 break;
6656
6657 case 15:
6658 case l_up:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6660 break;
6661
6662 332 tile+=80;
6663 332 break;
6664
6665 default:
6666 //dir=(zc_oldrand()*100)%8;
6667 //tiledir_big(dir);
6668 // flip=zc_oldrand()&3;
6669 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6670 break;
6671 }
6672 3868 }
6673
6674 40162690 void enemy::update_enemy_frame()
6675 {
6676
4/4
✓ Branch 0 taken 40160315 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40160308 times.
40162690 if(fallclk||drownclk) return;
6677
1/2
✓ Branch 0 taken 40160308 times.
✗ Branch 1 not taken.
40160308 if (!do_animation)
6678 return;
6679
6680
4/4
✓ Branch 0 taken 1549487 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 1547480 times.
✓ Branch 3 taken 2007 times.
40160308 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6681
6682
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40160308 if(get_qr(qr_ANONE_NOANIM)
6683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40160308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40160308 && anim == aNONE && type != eeGUY)
6684 return;
6685
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39788932 times.
40160308 int32_t newfrate = zc_max(frate,4);
6686 40160308 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6687 40160308 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6688
2/2
✓ Branch 0 taken 30164014 times.
✓ Branch 1 taken 9996294 times.
40160308 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6689 40160308 tile = o_tile;
6690 40160308 int32_t basetile = o_tile;
6691 40160308 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6692 40160308 bool ignore_extend = false;
6693
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5096784 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134724 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40160308 switch(anim)
6694 {
6695
6696 case aDONGO:
6697 {
6698 69324 int32_t fr = stunclk>0 ? 16 : 8;
6699
6700
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6701 {
6702 // bloated
6703
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6704 {
6705 case up:
6706 960 tile+=9;
6707 960 flip=0;
6708 960 xofs=0;
6709 960 dummy_int[1]=0; //no additional tiles
6710 960 break;
6711
6712 case down:
6713 960 tile+=7;
6714 960 flip=0;
6715 960 xofs=0;
6716 960 dummy_int[1]=0; //no additional tiles
6717 960 break;
6718
6719 case left:
6720 1664 flip=1;
6721 1664 tile+=4;
6722 1664 xofs=16;
6723 1664 dummy_int[1]=1; //second tile is next tile
6724 1664 break;
6725
6726 case right:
6727 896 flip=0;
6728 896 tile+=5;
6729 896 xofs=16;
6730 896 dummy_int[1]=-1; //second tile is previous tile
6731 896 break;
6732 }
6733 4480 }
6734
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6735 {
6736 // normal
6737
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6738 {
6739 case up:
6740 13652 tile+=8;
6741 13652 flip=(clk&fr)?1:0;
6742 13652 xofs=0;
6743 13652 dummy_int[1]=0; //no additional tiles
6744 13652 break;
6745
6746 case down:
6747 15374 tile+=6;
6748 15374 flip=(clk&fr)?1:0;
6749 15374 xofs=0;
6750 15374 dummy_int[1]=0; //no additional tiles
6751 15374 break;
6752
6753 case left:
6754 19615 flip=1;
6755 19615 tile+=(clk&fr)?2:0;
6756 19615 xofs=16;
6757 19615 dummy_int[1]=1; //second tile is next tile
6758 19615 break;
6759
6760 case right:
6761 15086 flip=0;
6762 15086 tile+=(clk&fr)?3:1;
6763 15086 xofs=16;
6764 15086 dummy_int[1]=-1; //second tile is next tile
6765 15086 break;
6766 }
6767 63727 }
6768 }
6769 69324 break;
6770
6771 case aNEWDONGO:
6772 {
6773 53456 int32_t fr4=0;
6774
6775
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6776 {
6777 // bloated
6778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6779 {
6780 2752 fr4=3;
6781 2752 }
6782
6783
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6784 {
6785 2107 fr4=2;
6786 2107 }
6787
6788
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6789 {
6790 1419 fr4=1;
6791 1419 }
6792
6793
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6794 {
6795 731 fr4=0;
6796 731 }
6797
6798
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6799 {
6800 case up:
6801 256 xofs=0;
6802 256 tile+=8+fr4;
6803 256 dummy_int[1]=0; //no additional tiles
6804 256 break;
6805
6806 case down:
6807 576 xofs=0;
6808 576 tile+=12+fr4;
6809 576 dummy_int[1]=0; //no additional tiles
6810 576 break;
6811
6812 case left:
6813 704 tile+=29+(2*fr4);
6814 704 xofs=16;
6815 704 dummy_int[1]=-1; //second tile is previous tile
6816 704 break;
6817
6818 case right:
6819 1216 tile+=49+(2*fr4);
6820 1216 xofs=16;
6821 1216 dummy_int[1]=-1; //second tile is previous tile
6822 1216 break;
6823 }
6824 2752 }
6825
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6826 {
6827 // normal
6828
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6829 {
6830 case up:
6831 9234 xofs=0;
6832 9234 tile+=((clk&12)>>2);
6833 9234 dummy_int[1]=0; //no additional tiles
6834 9234 break;
6835
6836 case down:
6837 9871 xofs=0;
6838 9871 tile+=4+((clk&12)>>2);
6839 9871 dummy_int[1]=0; //no additional tiles
6840 9871 break;
6841
6842 case left:
6843 15025 tile+=21+((clk&12)>>1);
6844 15025 xofs=16;
6845 15025 dummy_int[1]=-1; //second tile is previous tile
6846 15025 break;
6847
6848 case right:
6849 15676 flip=0;
6850 15676 tile+=41+((clk&12)>>1);
6851 15676 xofs=16;
6852 15676 dummy_int[1]=-1; //second tile is previous tile
6853 15676 break;
6854 }
6855 49806 }
6856 }
6857 53456 break;
6858
6859 case aDONGOBS:
6860 {
6861 38833 int32_t fr4=0;
6862
6863
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6864 {
6865 // bloated
6866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6867 {
6868 2688 fr4=3;
6869 2688 }
6870
6871
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6872 {
6873 2058 fr4=2;
6874 2058 }
6875
6876
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6877 {
6878 1386 fr4=1;
6879 1386 }
6880
6881
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6882 {
6883 714 fr4=0;
6884 714 }
6885
6886
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6887 {
6888 case up:
6889 256 tile+=28+fr4;
6890 256 yofs+=8;
6891 256 dummy_int[1]=-20; //second tile change
6892 256 dummy_int[2]=0; //new xofs change
6893 256 dummy_int[3]=-16; //new xofs change
6894 256 break;
6895
6896 case down:
6897 384 tile+=12+fr4;
6898 384 yofs-=8;
6899 384 dummy_int[1]=20; //second tile change
6900 384 dummy_int[2]=0; //new xofs change
6901 384 dummy_int[3]=16; //new xofs change
6902 384 break;
6903
6904 case left:
6905 1024 tile+=49+(2*fr4);
6906 1024 xofs+=8;
6907 1024 dummy_int[1]=-1; //second tile change
6908 1024 dummy_int[2]=-16; //new xofs change
6909 1024 dummy_int[3]=0; //new xofs change
6910 1024 break;
6911
6912 case right:
6913 1024 tile+=69+(2*fr4);
6914 1024 xofs+=8;
6915 1024 dummy_int[1]=-1; //second tile change
6916 1024 dummy_int[2]=-16; //new xofs change
6917 1024 dummy_int[3]=0; //new xofs change
6918 1024 break;
6919 }
6920 2688 }
6921
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6922 {
6923 // normal
6924
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6925 {
6926 case up:
6927 7136 tile+=20+((clk&24)>>3);
6928 7136 yofs+=8;
6929 7136 dummy_int[1]=-20; //second tile change
6930 7136 dummy_int[2]=0; //new xofs change
6931 7136 dummy_int[3]=-16; //new xofs change
6932 7136 break;
6933
6934 case down:
6935 6672 tile+=4+((clk&24)>>3);
6936 6672 yofs-=8;
6937 6672 dummy_int[1]=20; //second tile change
6938 6672 dummy_int[2]=0; //new xofs change
6939 6672 dummy_int[3]=16; //new xofs change
6940 6672 break;
6941
6942 case left:
6943 11075 xofs=-8;
6944 11075 tile+=40+((clk&24)>>2);
6945 11075 dummy_int[1]=1; //second tile change
6946 11075 dummy_int[2]=16; //new xofs change
6947 11075 dummy_int[3]=0; //new xofs change
6948 11075 break;
6949
6950 case right:
6951 10601 tile+=60+((clk&24)>>2);
6952 10601 xofs=-8;
6953 10601 dummy_int[1]=1; //second tile change
6954 10601 dummy_int[2]=16; //new xofs change
6955 10601 dummy_int[3]=0; //new xofs change
6956 10601 break;
6957 }
6958 35484 }
6959 }
6960 38833 break;
6961
6962 case aWIZZ:
6963 {
6964 // if(d->misc1)
6965
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6966 {
6967
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6968 {
6969 91127 ++tile;
6970 91127 }
6971 182184 }
6972 else
6973 {
6974
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6975 {
6976 136489 ++tile;
6977 136489 }
6978 }
6979
6980
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6981 {
6982 case 9:
6983 case 15:
6984 case up:
6985 76094 tile+=2;
6986 76094 break;
6987
6988 case down:
6989 76591 break;
6990
6991 case 13:
6992 case left:
6993 157108 flip=1;
6994 157108 break;
6995
6996 default:
6997 145581 flip=0;
6998 145581 break;
6999 }
7000 }
7001 455374 break;
7002
7003 case aNEWWIZZ:
7004 {
7005 1525813 tiledir(dir,true);
7006
7007 // if(d->misc1) //walking wizzrobe
7008
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7009 {
7010
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7011 {
7012 369103 tile+=2;
7013 369103 }
7014
7015
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7016 {
7017 370339 tile+=1;
7018 370339 }
7019
7020
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7021 {
7022
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7023 {
7024 79162 tile+=40;
7025 79162 }
7026 742424 }
7027 742424 }
7028 else
7029 {
7030
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7031 {
7032 235972 tile+=20;
7033
7034
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7035 {
7036 168836 tile+=20;
7037 168836 }
7038 235972 }
7039
7040 783389 tile+=((frame>>1)&3);
7041 }
7042 }
7043 1525813 break;
7044
7045 case a3FRM:
7046 {
7047
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7048 }
7049 197042 break;
7050
7051 case a3FRM4DIR:
7052 {
7053 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7054 }
7055 break;
7056
7057 case aVIRE:
7058 {
7059
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7060 {
7061 29292 tile+=2;
7062 29292 }
7063
7064 128880 tile+=fx;
7065 }
7066 128880 break;
7067
7068 case aROPE:
7069 {
7070 220021 tile+=(1-fx);
7071 220021 flip = dir==left ? 1:0;
7072 }
7073 220021 break;
7074
7075 case aZORA:
7076 {
7077 int32_t dl;
7078
7079
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7080 {
7081 46739 dl=clk+5;
7082 46739 goto waves2;
7083 }
7084
7085
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7086
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7087 else
7088 {
7089 92458 dl=clk-36-66;
7090 waves2:
7091 139197 tile=((dl/11)&1)+s_tile;
7092 139197 basetile = s_tile;
7093 }
7094 }
7095 221637 break;
7096
7097 case aNEWZORA:
7098 {
7099 693272 f4=(clk/16)%4;
7100
7101 693272 tiledir(dir,true);
7102 int32_t dl;
7103
7104
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7105 {
7106
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7107 {
7108 174585 tile+=80;
7109 174585 } //mouth closed
7110 else
7111 {
7112 64091 tile+=40;
7113 }
7114
7115 238676 tile+=f4;
7116 238676 }
7117 else
7118 {
7119
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7120 {
7121 203292 dl=clk+5;
7122 203292 }
7123 else
7124 {
7125 251304 dl=clk-36-66;
7126 }
7127
7128 454596 tile+=((dl/5)&3);
7129 }
7130 }
7131 693272 break;
7132
7133 case a4FRM4EYE:
7134 case a2FRM4EYE:
7135 case a4FRM8EYE:
7136 case a4FRM8EYEB: //big version
7137 case a4FRM4EYEB:
7138 {
7139 836734 tilerows = 2;
7140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7142 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7143 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7144 836734 int32_t lookat=zc_oldrand()&15;
7145
7146
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7147 {
7148 210774 lookat=l_down;
7149 210774 }
7150
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7151 {
7152 226850 lookat=down;
7153 226850 }
7154
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7155 {
7156 108837 lookat=r_down;
7157 108837 }
7158
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7159 {
7160 70395 lookat=right;
7161 70395 }
7162
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7163 {
7164 35067 lookat=r_up;
7165 35067 }
7166
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7167 {
7168 25436 lookat=up;
7169 25436 }
7170
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7171 {
7172 36803 lookat=l_up;
7173 36803 }
7174 else
7175 {
7176 122572 lookat=left;
7177 }
7178
7179 836734 int32_t dir2 = dir;
7180 836734 dir = lookat;
7181
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7182 else
7183 {
7184 tiledir_big(dir,(anim == a4FRM4EYEB));
7185 tile+=2*f4;
7186 ignore_extend = true;
7187 }
7188 836734 dir = dir2;
7189 }
7190 836734 break;
7191
7192 case aFLIP:
7193 {
7194 1694695 flip = f2&1;
7195 }
7196 1694695 break;
7197
7198 case a2FRM:
7199 {
7200 1134909 tile += (1-f2);
7201 }
7202 1134909 break;
7203
7204 case a2FRMB:
7205 {
7206 tile+= 2*(1-f2);
7207 ignore_extend = true;
7208 }
7209 break;
7210
7211 case a2FRM4DIR:
7212 {
7213 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7214 }
7215 267131 break;
7216
7217 case a4FRM4DIRF:
7218 {
7219 4134724 basetile = n_frame_n_dir(4,4,f4);
7220
7221
2/2
✓ Branch 0 taken 2733716 times.
✓ Branch 1 taken 1401008 times.
4134724 if(clk2>0) //stopped to fire
7222 {
7223 1401008 tile+=20;
7224
7225
2/2
✓ Branch 0 taken 698282 times.
✓ Branch 1 taken 702726 times.
1401008 if(clk2<17) //firing
7226 {
7227 702726 tile+=20;
7228 702726 }
7229 1401008 }
7230 }
7231 4134724 break;
7232
7233 case a4FRM4DIR:
7234 {
7235 7515986 basetile = n_frame_n_dir(4,4,f4);
7236 }
7237 7515986 break;
7238
7239 case a4FRM8DIRF:
7240 {
7241 tilerows = 2;
7242 basetile = n_frame_n_dir(4,8,f4);
7243
7244 if(clk2>0) //stopped to fire
7245 {
7246 tile+=40;
7247
7248 if(clk2<17) //firing
7249 {
7250 tile+=40;
7251 }
7252 }
7253 }
7254 break;
7255
7256 case a4FRM8DIRB:
7257 case a4FRM8DIRFB:
7258 {
7259 3868 tilerows = 2;
7260 3868 tiledir_big(dir,false);
7261 3868 tile+=2*f4;
7262
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7263 {
7264 tile+=80;
7265
7266 if(clk2<17) //firing
7267 {
7268 tile+=80;
7269 }
7270 }
7271 3868 ignore_extend = true;
7272 }
7273 3868 break;
7274
7275 case a4FRM4DIRB:
7276 case a4FRM4DIRFB:
7277 {
7278 tilerows = 2;
7279 tiledir_big(dir,true);
7280 tile+=2*f4;
7281 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7282 {
7283 tile+=40;
7284
7285 if(clk2<17) //firing
7286 {
7287 tile+=40;
7288 }
7289 }
7290 ignore_extend = true;
7291 }
7292 break;
7293
7294 case aOCTO:
7295 {
7296
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7297 {
7298 case up:
7299 122459 flip = 2;
7300 122459 break;
7301
7302 case down:
7303 133448 flip = 0;
7304 133448 break;
7305
7306 case left:
7307 165651 flip = 0;
7308 165651 tile += 2;
7309 165651 break;
7310
7311 case right:
7312 157227 flip = 1;
7313 157227 tile += 2;
7314 157227 break;
7315 }
7316
7317 582937 tile+=f2;
7318 }
7319 582937 break;
7320
7321 case aWALK:
7322 {
7323
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7324 {
7325 case up:
7326 248704 tile+=3;
7327 248704 flip = f2;
7328 248704 break;
7329
7330 case down:
7331 267165 tile+=2;
7332 267165 flip = f2;
7333 267165 break;
7334
7335 case left:
7336 331694 flip=1;
7337 331694 tile += f2;
7338 331694 break;
7339
7340 case right:
7341 325802 flip=0;
7342 325802 tile += f2;
7343 325802 break;
7344 }
7345 }
7346 1178979 break;
7347
7348 case aDWALK:
7349 {
7350
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7351 {
7352 tile=s_tile;
7353 basetile = s_tile;
7354 }
7355
7356
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7357 {
7358 case up:
7359 177728 tile+=2;
7360 177728 flip=f2;
7361 177728 break;
7362
7363 case down:
7364 185581 flip=0;
7365 185581 tile+=(1-f2);
7366 185581 break;
7367
7368 case left:
7369 260885 flip=1;
7370 260885 tile+=(3+f2);
7371 260885 break;
7372
7373 case right:
7374 255982 flip=0;
7375 255982 tile+=(3+f2);
7376 255982 break;
7377 }
7378 }
7379 880176 break;
7380
7381 case aTEK:
7382 {
7383
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7384 {
7385 79120 tile += f2;
7386 79120 }
7387
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7388 {
7389 66827 ++tile;
7390 66827 }
7391 }
7392 219096 break;
7393
7394 case aNEWTEK:
7395 {
7396
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7397 {
7398
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7399 {
7400 case left:
7401 235369 flip=0;
7402 235369 tile+=20;
7403 235369 break;
7404
7405 case right:
7406 239877 flip=0;
7407 239877 tile+=24;
7408 239877 break;
7409 }
7410 475246 }
7411
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7412 {
7413
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7414 {
7415 case left:
7416 40566 flip=0;
7417 40566 tile+=8;
7418 40566 break;
7419
7420 case right:
7421 14183 flip=0;
7422 14183 tile+=12;
7423 14183 break;
7424 }
7425 54749 } //down
7426 else
7427 {
7428
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7429 {
7430 case left:
7431 593340 flip=0;
7432 593340 tile+=28;
7433 593340 break;
7434
7435 case right:
7436 585820 flip=0;
7437 585820 tile+=32;
7438 585820 break;
7439 }
7440 }
7441
7442
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7443 {
7444 579549 tile+=f4;
7445 579549 }
7446
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7447 {
7448 656670 tile+=2;
7449 656670 }
7450 }
7451 1818304 break;
7452
7453 case aARMOS:
7454 {
7455
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7456 {
7457 5401 tile += fx;
7458
7459
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7460 1197 tile += 2;
7461 5401 }
7462 }
7463 8628 break;
7464
7465 case aARMOS4:
7466 {
7467
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7468 {
7469 case up:
7470 29165 flip=0;
7471 29165 break;
7472
7473 case down:
7474 92624 flip=0;
7475 92624 tile+=4;
7476 92624 break;
7477
7478 case left:
7479 43654 flip=0;
7480 43654 tile+=8;
7481 43654 break;
7482
7483 case right:
7484 43190 flip=0;
7485 43190 tile+=12;
7486 43190 break;
7487 }
7488
7489
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7490 {
7491 145928 tile+=f4;
7492 145928 }
7493 }
7494 209083 break;
7495
7496 case aGHINI:
7497 {
7498
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7499 {
7500 case 8:
7501 case 9:
7502 case up:
7503 28037 ++tile;
7504 28037 flip=0;
7505 28037 break;
7506
7507 case 15:
7508 452 ++tile;
7509 452 flip=1;
7510 452 break;
7511
7512 case 10:
7513 case 11:
7514 case right:
7515 32092 flip=1;
7516 32092 break;
7517
7518 default:
7519 72763 flip=0;
7520 72763 break;
7521 }
7522 }
7523 133344 break;
7524
7525 case a2FRMPOS:
7526 {
7527 1755010 tile+=posframe;
7528 }
7529 1755010 break;
7530
7531 case a4FRMPOS4DIR:
7532 {
7533 363745 basetile = n_frame_n_dir(4,4,0);
7534 // tile+=f2;
7535 363745 tile+=posframe;
7536 }
7537 363745 break;
7538
7539 case a4FRMPOS4DIRF:
7540 {
7541 1433 basetile = n_frame_n_dir(4,4,0);
7542
7543
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7544 {
7545 197 tile+=20;
7546
7547
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7548 {
7549 64 tile+=20;
7550 64 }
7551 197 }
7552
7553 // tile+=f2;
7554 1433 tile+=posframe;
7555 }
7556 1433 break;
7557
7558 case a4FRMPOS8DIR:
7559 {
7560 7018408 tilerows = 2;
7561 7018408 int32_t n = tile;
7562 7018408 basetile = n_frame_n_dir(4,8,0);
7563 // tile+=f2;
7564 7018408 tile+=posframe;
7565 }
7566 7018408 break;
7567
7568 case a4FRMPOS8DIRF:
7569 {
7570 tilerows = 2;
7571 basetile = n_frame_n_dir(4,8,0);
7572
7573 if(clk2>0) //stopped to fire
7574 {
7575 tile+=40;
7576
7577 if(clk2<17) //firing
7578 {
7579 tile+=40;
7580 }
7581 }
7582
7583 tile+=posframe;
7584 }
7585 break;
7586
7587 case aNEWLEV:
7588 {
7589 747030 tiledir(dir,true);
7590
7591
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7592 {
7593 case -1:
7594 case 0:
7595 258994 return;
7596
7597 case 1:
7598
7599 // case 5: cs = d->misc2; break;
7600 case 5:
7601 115368 cs = dmisc2;
7602 115368 break;
7603
7604 case 2:
7605 case 4:
7606 48980 tile += 20;
7607 48980 break;
7608
7609 case 3:
7610 323688 tile += 40;
7611 323688 break;
7612 }
7613
7614 488036 tile+=f4;
7615 }
7616 488036 break;
7617
7618 case aLEV:
7619 {
7620 276997 f4 = ((clk/5)&1);
7621
7622
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7623 {
7624 case -1:
7625 case 0:
7626 127945 return;
7627
7628 case 1:
7629
7630 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7631 case 5:
7632 33336 tile += (f2) ? 1 : 0;
7633 33336 cs = dmisc2;
7634 33336 break;
7635
7636 case 2:
7637 case 4:
7638 14658 tile += 2;
7639 14658 break;
7640
7641 case 3:
7642 101058 tile += (f4) ? 4 : 3;
7643 101058 break;
7644 }
7645 }
7646 149052 break;
7647
7648 case aWALLM:
7649 {
7650
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7651 {
7652 139764 tile += f2;
7653 139764 }
7654 }
7655 140514 break;
7656
7657 case aNEWWALLM:
7658 {
7659 366633 int32_t tempdir=0;
7660
7661
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7662 {
7663 case 1:
7664 case 2:
7665 43340 tempdir=clk3;
7666 43340 break;
7667
7668 case 3:
7669 case 4:
7670 case 5:
7671 38855 tempdir=dir;
7672 38855 break;
7673
7674 case 6:
7675 case 7:
7676 8438 tempdir=clk3^1;
7677 8438 break;
7678 }
7679
7680 366633 tiledir(tempdir,true);
7681
7682
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7683 {
7684 364725 tile+=f4;
7685 364725 }
7686 }
7687 366633 break;
7688
7689 case a4FRMNODIR:
7690 {
7691 171508 tile+=f4;
7692 }
7693 171508 break;
7694
7695 } // switch(d->anim)
7696
7697 // flashing
7698 // if(d->flags & guy_flashing)
7699
2/2
✓ Branch 0 taken 39025820 times.
✓ Branch 1 taken 747549 times.
39773369 if(flags & guy_flashing)
7700 {
7701 747549 cs = (frame&3) + 6;
7702 747549 }
7703
7704
2/2
✓ Branch 0 taken 39362421 times.
✓ Branch 1 taken 410948 times.
39773369 if(flags&guy_transparent)
7705 {
7706 410948 drawstyle=1;
7707 410948 }
7708
7709 39773369 int32_t change = tile-basetile;
7710
7711
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37718426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39773369 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7712 {
7713
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7714 {
7715 1792915 tile=basetile+txsz*change;
7716 1792915 }
7717 else
7718 {
7719 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7720 }
7721 2054943 }
7722 else
7723 {
7724 37718426 tile=basetile+change;
7725 }
7726 40162690 }
7727
7728 81117 int32_t enemy::wpnsfx(int32_t wpn)
7729 {
7730
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40991 times.
✓ Branch 2 taken 17707 times.
81117 switch (wpn)
7731 {
7732 case wScript1:
7733 case wScript2:
7734 case wScript3:
7735 case wScript4:
7736 case wScript5:
7737 case wScript6:
7738 case wScript7:
7739 case wScript8:
7740 case wScript9:
7741 case wScript10: //sure why not
7742 case ewFireTrail:
7743 case ewFlame:
7744 case ewFlame2Trail:
7745 case ewFlame2:
7746 case ewWind:
7747 case ewMagic:
7748 case ewIce:
7749 22419 return firesfx;
7750
7751 case ewRock:
7752 case ewFireball2:
7753 case ewFireball:
7754
2/2
✓ Branch 0 taken 5533 times.
✓ Branch 1 taken 35458 times.
40991 if (get_qr(qr_MORESOUNDS)) return firesfx;
7755 35458 break;
7756 }
7757
7758 53165 return 0;
7759 81117 }
7760
7761 77044177 int32_t enemy::run_script(int32_t mode)
7762 {
7763 void push_ri();
7764 void pop_ri();
7765
7766
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
77044177 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7767
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77043921 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7768 77043921 return RUNSCRIPT_OK;
7769 auto scrty = *get_scrtype();
7770 auto uid = getUID();
7771 if(!FFCore.doscript(scrty,uid))
7772 return RUNSCRIPT_OK;
7773 int32_t ret = RUNSCRIPT_OK;
7774 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7775 push_ri();
7776 switch(mode)
7777 {
7778 case MODE_NORMAL:
7779 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7780 break;
7781
7782 case MODE_WAITDRAW:
7783 if(waitdraw)
7784 {
7785 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7786 waitdraw = false;
7787 }
7788 break;
7789 }
7790 pop_ri();
7791 return ret;
7792 77044177 }
7793 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7794 {
7795 return al_map_rgba(255,0,0,opacity);
7796 }
7797
7798 // good guys, fires, fairy, and other non-enemies
7799 // based on enemy class b/c guys in dungeons act sort of like enemies
7800 // also easier to manage all the guys this way
7801 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7802 2191 {
7803 2191 mainguy=mg;
7804 2191 canfreeze=false;
7805 2191 dir=down;
7806
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7807 2191 hxofs=2;
7808 2191 hzsz=8;
7809 2191 hit_width=12;
7810 2191 hit_height=17;
7811
7812
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7813 {
7814 1931 superman = 1;
7815 1931 hxofs=1000;
7816 1931 }
7817 2191 }
7818
7819 943762 bool guy::animate(int32_t index)
7820 {
7821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7822
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7823 {
7824 1206 setupscreen();
7825 1206 misc = 1;
7826 1206 }
7827
7828
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7829 330 return true;
7830
7831 943432 hp=256; // good guys never die...
7832
7833
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7834 {
7835 // but if they get hit...
7836 16 ++clk2; // only do this once
7837
7838
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7839 {
7840 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7841 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7842 7 }
7843 16 }
7844
7845 943432 return enemy::animate(index);
7846 943762 }
7847
7848 947535 void guy::draw(BITMAP *dest)
7849 {
7850 947535 update_enemy_frame();
7851
7852
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7853 935688 enemy::draw(dest);
7854 947535 }
7855
7856 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7857 760 {
7858 760 clk4=0;
7859
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7860 // Spawn type
7861
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7862 {
7863 clk=0;
7864 superman = 1;
7865 fading=fade_flicker;
7866 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7867 dir=down;
7868
7869 if(!canmove(down,(zfix)8,spw_none,false))
7870 clk3=int32_t(13.0/step);
7871 }
7872
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7873 {
7874 84 clk=0;
7875 84 }
7876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7877 760 }
7878
7879 167472 bool eFire::animate(int32_t index)
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7882
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7883
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7884 {
7885
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7886 {
7887 1 clk4=0;
7888 1 superman=0;
7889 1 fading=0;
7890
7891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7892 removearmos(x,y);
7893
7894 1 clk2=0;
7895
7896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7897 {
7898 1 dir=0;
7899 1 y = TRUNCATE_TILE(y.getInt());
7900 1 }
7901
7902 1 return Dead(index);
7903 }
7904
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7905 removearmos(x,y);
7906 1715 }
7907
7908 167471 return enemy::animate(index);
7909 167472 }
7910
7911 351659 void eFire::draw(BITMAP *dest)
7912 {
7913 351659 update_enemy_frame();
7914 351659 enemy::draw(dest);
7915 351659 }
7916
7917 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7918 {
7919 415 int32_t wpnId = w->id;
7920 415 int32_t wpnDir = w->dir;
7921
7922
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7923 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7924 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7925 {
7926 shield = false;
7927 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7928
7929 if(get_qr(qr_BRKNSHLDTILES))
7930 o_tile=s_tile;
7931 }
7932
7933 415 int32_t ret = enemy::takehit(w,realweap);
7934 415 return ret;
7935 }
7936
7937 void eFire::break_shield()
7938 {
7939 if(!shield)
7940 return;
7941
7942 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7943 shield=false;
7944
7945 if(get_qr(qr_BRKNSHLDTILES))
7946 o_tile=s_tile;
7947 }
7948
7949 void eFire::repair_shield()
7950 {
7951 if (shield)
7952 return;
7953
7954 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7955 return;
7956
7957 shield = true;
7958
7959 if (get_qr(qr_BRKNSHLDTILES))
7960 {
7961 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7962 else o_tile = d->tile;
7963 }
7964 }
7965
7966 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7967 7630 {
7968 7630 clk4=0;
7969
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7970
7971 // Spawn type
7972
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7973 {
7974 clk=0;
7975 superman = 1;
7976 fading=fade_flicker;
7977 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7978 dir=down;
7979
7980 if(!canmove(down,(zfix)8,spw_none,false))
7981 clk3=int32_t(13.0/step);
7982 }
7983
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7984 {
7985 1187 clk=0;
7986 1187 }
7987
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7988 7630 }
7989
7990 1981512 bool eOther::animate(int32_t index)
7991 {
7992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7993
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7994
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7995 {
7996
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7997 {
7998 29 clk4=0;
7999 29 superman=0;
8000 29 fading=0;
8001
8002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8003 removearmos(x,y);
8004
8005 29 clk2=0;
8006
8007
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8008 {
8009 2 dir=0;
8010 2 y = TRUNCATE_TILE(y.getInt());
8011 2 }
8012
8013 29 return Dead(index);
8014 }
8015
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8016 removearmos(x,y);
8017 8507 }
8018
8019 1979897 return enemy::animate(index);
8020 1981512 }
8021
8022 2087673 void eOther::draw(BITMAP *dest)
8023 {
8024 2087673 update_enemy_frame();
8025 2087673 enemy::draw(dest);
8026 2087673 }
8027
8028 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8029 {
8030 14773 int32_t wpnId = w->id;
8031 14773 int32_t wpnDir = w->dir;
8032
8033
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8034 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8035 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8036 {
8037 shield = false;
8038 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8039
8040 if(get_qr(qr_BRKNSHLDTILES))
8041 o_tile=s_tile;
8042 }
8043
8044 14773 int32_t ret = enemy::takehit(w,realweap);
8045 14773 return ret;
8046 }
8047
8048 void eOther::break_shield()
8049 {
8050 if(!shield)
8051 return;
8052
8053 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8054 shield=false;
8055
8056 if(get_qr(qr_BRKNSHLDTILES))
8057 o_tile=s_tile;
8058 }
8059
8060 void eOther::repair_shield()
8061 {
8062 if (shield)
8063 return;
8064
8065 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8066 return;
8067
8068 shield = true;
8069
8070 if (get_qr(qr_BRKNSHLDTILES))
8071 {
8072 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8073 else o_tile = d->tile;
8074 }
8075 }
8076
8077 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8078 {
8079 clk4=0;
8080 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8081
8082 // Spawn type
8083 if(flags & guy_fade_flicker)
8084 {
8085 clk=0;
8086 superman = 1;
8087 fading=fade_flicker;
8088 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8089 dir=down;
8090
8091 if(!canmove(down,(zfix)8,spw_none,false))
8092 clk3=int32_t(13.0/step);
8093 }
8094 else if(flags & guy_fade_instant)
8095 {
8096 clk=0;
8097 }
8098 if (SIZEflags != 0) init_size_flags();;
8099 }
8100
8101 bool eScript::animate(int32_t index)
8102 {
8103 if(switch_hooked) return enemy::animate(index);
8104 if(fallclk||drownclk) return enemy::animate(index);
8105 if(fading)
8106 {
8107 if(++clk4 > 60)
8108 {
8109 clk4=0;
8110 superman=0;
8111 fading=0;
8112
8113 if(flags&guy_armos && z==0 && fakez==0)
8114 removearmos(x,y);
8115
8116 clk2=0;
8117
8118 if(!canmove(down,(zfix)8,spw_none,false))
8119 {
8120 dir=0;
8121 y = TRUNCATE_TILE(y.getInt());
8122 }
8123
8124 return Dead(index);
8125 }
8126 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8127 removearmos(x,y);
8128 }
8129
8130 return enemy::animate(index);
8131 }
8132
8133 void eScript::draw(BITMAP *dest)
8134 {
8135 update_enemy_frame();
8136 enemy::draw(dest);
8137 }
8138
8139 int32_t eScript::takehit(weapon *w, weapon* realweap)
8140 {
8141 int32_t wpnId = w->id;
8142 int32_t wpnDir = w->dir;
8143
8144 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8145 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8146 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8147 {
8148 shield = false;
8149 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8150
8151 if(get_qr(qr_BRKNSHLDTILES))
8152 o_tile=s_tile;
8153 }
8154
8155 int32_t ret = enemy::takehit(w,realweap);
8156 return ret;
8157 }
8158
8159 void eScript::break_shield()
8160 {
8161 if(!shield)
8162 return;
8163
8164 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8165 shield=false;
8166
8167 if(get_qr(qr_BRKNSHLDTILES))
8168 o_tile=s_tile;
8169 }
8170
8171 void eScript::repair_shield()
8172 {
8173 if (shield)
8174 return;
8175
8176 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8177 return;
8178
8179 shield = true;
8180
8181 if (get_qr(qr_BRKNSHLDTILES))
8182 {
8183 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8184 else o_tile = d->tile;
8185 }
8186 }
8187
8188
8189 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8190 {
8191 clk4=0;
8192 hyofs = -32768; //No hitbox initially.
8193 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8194
8195 // Spawn type
8196 if(flags & guy_fade_flicker)
8197 {
8198 clk=0;
8199 superman = 1;
8200 fading=fade_flicker;
8201 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8202 dir=down;
8203
8204 if(!canmove(down,(zfix)8,spw_none,false))
8205 clk3=int32_t(13.0/step);
8206 }
8207 else if(flags & guy_fade_instant)
8208 {
8209 clk=0;
8210 }
8211 if (SIZEflags != 0) init_size_flags();;
8212 }
8213
8214 bool eFriendly::animate(int32_t index)
8215 {
8216 if(switch_hooked) return enemy::animate(index);
8217 if(fallclk||drownclk) return enemy::animate(index);
8218 if(fading)
8219 {
8220 if(++clk4 > 60)
8221 {
8222 clk4=0;
8223 superman=0;
8224 fading=0;
8225
8226 if(flags&guy_armos && z==0 && fakez==0)
8227 removearmos(x,y);
8228
8229 clk2=0;
8230
8231 if(!canmove(down,(zfix)8,spw_none,false))
8232 {
8233 dir=0;
8234 y = TRUNCATE_TILE(y.getInt());
8235 }
8236
8237 return Dead(index);
8238 }
8239 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8240 removearmos(x,y);
8241 }
8242
8243 return enemy::animate(index);
8244 }
8245
8246 void eFriendly::draw(BITMAP *dest)
8247 {
8248 update_enemy_frame();
8249 enemy::draw(dest);
8250 }
8251
8252 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8253 {
8254 int32_t wpnId = w->id;
8255 int32_t wpnDir = w->dir;
8256
8257 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8258 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8259 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8260 {
8261 shield = false;
8262 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8263
8264 if(get_qr(qr_BRKNSHLDTILES))
8265 o_tile=s_tile;
8266 }
8267
8268 int32_t ret = enemy::takehit(w,realweap);
8269 return ret;
8270 }
8271
8272 void eFriendly::break_shield()
8273 {
8274 if(!shield)
8275 return;
8276
8277 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8278 shield=false;
8279
8280 if(get_qr(qr_BRKNSHLDTILES))
8281 o_tile=s_tile;
8282 }
8283
8284 void eFriendly::repair_shield()
8285 {
8286 if (shield)
8287 return;
8288
8289 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8290 return;
8291
8292 shield = true;
8293
8294 if (get_qr(qr_BRKNSHLDTILES))
8295 {
8296 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8297 else o_tile = d->tile;
8298 }
8299 }
8300
8301
8302 780032 void enemy::removearmos(int32_t ax,int32_t ay)
8303 {
8304
2/2
✓ Branch 0 taken 779016 times.
✓ Branch 1 taken 1016 times.
780032 if(did_armos)
8305 779016 return;
8306 1016 did_armos=true;
8307 1016 auto handle = activated_handle;
8308
8309
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 700 times.
1016 auto layer = handle ? handle->layer() : 0;
8310
3/4
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 700 times.
✓ Branch 2 taken 316 times.
✗ Branch 3 not taken.
1016 if (!handle || handle->is_rpos())
8311 1016 handle = get_rpos_handle_for_world_xy(ax, ay, layer);
8312 1016 mapscr* scr = handle->get_mapscr();
8313
8314 1374 auto [tx, ty] = handle->xy();
8315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
1016 if (handle->is_rpos())
8316 {
8317 2032 tx = TRUNCATE_TILE(ax);
8318 2032 ty = TRUNCATE_TILE(ay);
8319 1016 }
8320
8321 1016 int32_t f = handle->sflag();
8322 1016 int32_t f2 = handle->cflag();
8323
8324
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (handle->ctype() != cARMOS)
8325 840 return;
8326
8327
8328
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8329 {
8330 22 handle->set_data(scr->secretcombo[sSTAIRS]);
8331 22 handle->set_cset(scr->secretcset[sSTAIRS]);
8332 22 handle->set_sflag(scr->secretflag[sSTAIRS]);
8333 22 sfx(scr->secretsfx);
8334 22 }
8335 else
8336 {
8337 154 handle->set_data(scr->undercombo);
8338 154 handle->set_cset(scr->undercset);
8339 154 handle->set_sflag(0);
8340 }
8341
8342
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8343 {
8344
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8345 {
8346 6 additem(tx,ty,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8347 3 sfx(scr->secretsfx);
8348 3 }
8349 3 }
8350
8351 528 putcombo(scrollbuf,tx,ty,handle->data(),handle->cset());
8352 780032 }
8353
8354 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8355 461 {
8356 461 fading=fade_flicker;
8357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8358 461 dir=12;
8359 461 movestatus=1;
8360
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8361 461 clk=0;
8362 461 clk4=0;
8363
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8364 461 }
8365
8366 117025 bool eGhini::animate(int32_t index)
8367 {
8368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8369
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8370
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8371 50 return Dead(index);
8372
8373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8374 {
8375
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8376 {
8377
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8378 54853 misc=2;
8379
8380
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8381 89752 removearmos(x,y);
8382 89752 }
8383
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8384 {
8385 425 misc=1;
8386 425 clk3=32;
8387 425 fading=0;
8388
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 285 times.
425 if (activated_handle)
8389 {
8390 140 activation_counters[activated_handle->layer()][activated_handle->id()] = 0;
8391 140 removearmos(x, y);
8392 140 }
8393 else
8394 {
8395 285 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8396
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if (rpos != rpos_t::None)
8397 {
8398 285 activation_counters[0][int(rpos)] = 0;
8399 285 removearmos(x,y);
8400 285 }
8401 }
8402 425 }
8403 116975 }
8404
8405 116975 clk4++;
8406
8407 116975 return enemy::animate(index);
8408 117025 }
8409
8410 238808 void eGhini::draw(BITMAP *dest)
8411 {
8412 238808 update_enemy_frame();
8413 238808 enemy::draw(dest);
8414 238808 }
8415
8416 2 void eGhini::kickbucket()
8417 {
8418 2 hp=-1000; // don't call death_sfx()
8419 2 }
8420
8421
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8422 5212 {
8423
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8424 5212 dir=down;
8425 5212 misc=1;
8426 5212 clk=-15;
8427
8428
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8429
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8430
8431 // avoid divide by 0 errors
8432
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8433 dmisc1 = 24;
8434
8435
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8436 dmisc2 = 3;
8437
8438 //nets+760;
8439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8440 5212 }
8441
8442 1436534 bool eTektite::animate(int32_t index)
8443 {
8444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436534 times.
1436534 if(switch_hooked) return enemy::animate(index);
8445
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8890 times.
✓ Branch 2 taken 8890 times.
✓ Branch 3 taken 1425170 times.
1436534 if(fallclk||drownclk) return enemy::animate(index);
8446
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398503 times.
1425170 if(dying)
8447 26667 return Dead(index);
8448
8449
2/2
✓ Branch 0 taken 1361400 times.
✓ Branch 1 taken 37103 times.
1398503 if(clk==0)
8450 {
8451 37103 removearmos(x,y);
8452 37103 }
8453
8454
2/2
✓ Branch 0 taken 1057320 times.
✓ Branch 1 taken 341183 times.
1398503 if(get_qr(qr_ENEMIESZAXIS))
8455 {
8456 341183 y=floor_y;
8457 341183 }
8458
8459
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114764 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 12032 times.
✓ Branch 9 taken 21878 times.
1398503 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8460 {
8461
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8462 {
8463 case 0: // normal
8464
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8465 {
8466 11233 misc=1;
8467 11233 clk2=32;
8468 11233 }
8469
8470 421702 break;
8471
8472 case 1: // waiting to pounce
8473
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8474 {
8475 20635 int32_t r=zc_oldrand();
8476 20635 misc=2;
8477 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8478 20635 clk3=(r&1)+2; // left or right
8479 20635 clk2start=clk2=(r&31)+10; // flight time
8480
8481
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8482
8483
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8484
8485 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8486 20635 }
8487
8488 345150 break;
8489
8490 case 2: // in flight
8491 493765 move(step);
8492
8493
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8494 {
8495
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8496 {
8497 632 step=0-step;
8498 632 }
8499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8500 {
8501 step=0-step;
8502 }
8503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8504 {
8505 step=0-step;
8506 }
8507
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8508 {
8509 47 step=0-step;
8510 47 }
8511
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8512 {
8513 11 step=0-step;
8514 11 }
8515 234357 }
8516
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8517 {
8518
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8519 {
8520 438 step=0-step;
8521 438 }
8522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8523 {
8524 step=0-step;
8525 }
8526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8527 {
8528 step=0-step;
8529 }
8530
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8531 {
8532 21 step=0-step;
8533 21 }
8534
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8535 {
8536 19 step=0-step;
8537 19 }
8538 244242 }
8539
8540
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8541 {
8542
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8543 {
8544 275 clk3^=1;
8545 275 }
8546
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8547 {
8548 6 clk3^=1;
8549 6 }
8550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8551 {
8552 clk3^=1;
8553 }
8554
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8555 {
8556 30 clk3^=1;
8557 30 }
8558
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8559 {
8560 12 clk3^=1;
8561 12 }
8562 244331 }
8563 else
8564 {
8565
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8566 {
8567 276 clk3^=1;
8568 276 }
8569
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8570 {
8571 12 clk3^=1;
8572 12 }
8573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8574 {
8575 clk3^=1;
8576 }
8577
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8578 {
8579 5 clk3^=1;
8580 5 }
8581
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8582 {
8583 12 clk3^=1;
8584 12 }
8585 }
8586
8587 493765 --c;
8588
8589
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8590 {
8591 173077 step+=zslongToFix(dmisc3*100);
8592 173077 }
8593
8594 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8595
8596
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8597
8598
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8599
8600 493765 x += (clk3==left) ? -1 : 1;
8601
8602
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8603 {
8604
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8605 {
8606 185 step=0-step;
8607 185 y--;
8608 185 }
8609
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8610 {
8611 12928 clk=misc=0;
8612 12928 } //land and jump again
8613 else
8614 {
8615 5796 misc=1;
8616 5796 clk2=0;
8617 }
8618 18909 }
8619
8620 473505 break;
8621 } // switch
8622 1260617 }
8623
8624
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8625 {
8626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8627 {
8628 int32_t tempy = floor_y;
8629 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8630 floor_y = y;
8631 y=tempy-fakez;
8632 old_y = y;
8633 }
8634 else
8635 {
8636 109977 int32_t tempy = floor_y;
8637
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8638 109977 floor_y = y;
8639 109977 y=tempy-z;
8640 109977 old_y = y;
8641 }
8642 109977 }
8643
8644
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8645 10637 clk=0;
8646
8647 1400977 return enemy::animate(index);
8648 1427644 }
8649
8650 982496 bool eTektite::can_drawshadow() const
8651 {
8652
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 350324 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25191 times.
✓ Branch 5 taken 606981 times.
982496 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8653 25191 return false;
8654
8655 957305 return enemy::can_drawshadow();
8656 982496 }
8657 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8658 {
8659
2/2
✓ Branch 0 taken 636404 times.
✓ Branch 1 taken 173046 times.
809450 if(!can_drawshadow())
8660 636404 return;
8661
8662 173046 int32_t tempy=yofs;
8663 173046 int32_t fdiv = frate/4;
8664
1/2
✓ Branch 0 taken 173046 times.
✗ Branch 1 not taken.
173046 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8665
1/2
✓ Branch 0 taken 173046 times.
✗ Branch 1 not taken.
173046 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8666 173046 efrate:((clk>=(frate>>1))?1:0);
8667 173046 flip = 0;
8668 173046 shadowtile = wpnsbuf[spr_shadow].tile;
8669
8670
1/2
✓ Branch 0 taken 173046 times.
✗ Branch 1 not taken.
173046 if(get_qr(qr_NEWENEMYTILES))
8671 {
8672
2/2
✓ Branch 0 taken 106580 times.
✓ Branch 1 taken 66466 times.
173046 if(misc==0)
8673 {
8674 66466 shadowtile+=f2;
8675 66466 }
8676
2/2
✓ Branch 0 taken 47644 times.
✓ Branch 1 taken 58936 times.
106580 else if(misc!=1)
8677 58936 shadowtile+=2;
8678 173046 }
8679 else
8680 {
8681 if(misc==0)
8682 {
8683 shadowtile += f2 ? 1 : 0;
8684 }
8685 else if(misc!=1)
8686 {
8687 ++shadowtile;
8688 }
8689 }
8690
8691 173046 yofs+=8;
8692
8693
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 173046 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
173046 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8694 {
8695 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8696 }
8697 173046 enemy::drawshadow(dest,translucent);
8698 173046 yofs=tempy;
8699 809450 }
8700
8701 2052032 void eTektite::draw(BITMAP *dest)
8702 {
8703 2052032 update_enemy_frame();
8704 2052032 enemy::draw(dest);
8705 2052032 }
8706
8707 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8708 732 {
8709
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8710 732 superman=1;
8711 732 dir=8;
8712 732 hxofs=1000;
8713 732 mainguy=false;
8714 732 count_enemy=false;
8715
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8716 732 }
8717
8718 280245 bool eItemFairy::animate(int32_t index)
8719 {
8720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8722 return Dead(index);
8723
8724 //if(clk>32)
8725 280245 misc=1;
8726 280245 bool w=watch;
8727 280245 watch=false;
8728 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8729 280245 watch=w;
8730
8731
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8732 {
8733 1516 removearmos(x,y);
8734 1516 }
8735
8736 280245 return enemy::animate(index);
8737 280245 }
8738
8739 562846 void eItemFairy::draw(BITMAP *dest)
8740 {
8741 //these are here to bypass compiler warnings about unused arguments
8742 562846 dest=dest;
8743 562846 }
8744
8745 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8746 1825 {
8747 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8748
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8749 1825 dir=8;
8750 1825 movestatus=1;
8751 1825 clk=0;
8752
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8753 //nets+720;
8754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8755 1825 }
8756
8757 520615 bool ePeahat::animate(int32_t index)
8758 {
8759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8760
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8761
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8762 {
8763 78 update_current_screen();
8764 78 return false;
8765 }
8766
8767
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8768 1030 return Dead(index);
8769
8770
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8771 {
8772 3083 removearmos(x,y);
8773 3083 }
8774
8775
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8776 263053 misc=1;
8777
8778
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8779
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8780
8781
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8782 {
8783
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8784 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8785 100018 }
8786
8787
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8788 1634 superman=0;
8789 else
8790
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8791 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8792
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8793 {
8794
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8795 264937 }
8796 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8797 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8798
8799
8800
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8801
8802 519507 return enemy::animate(index);
8803 520615 }
8804
8805 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8806 {
8807 334520 flip = 0;
8808
2/2
✓ Branch 0 taken 252495 times.
✓ Branch 1 taken 82025 times.
334520 if(!can_drawshadow())
8809 252495 return;
8810 82025 int32_t tempy=yofs;
8811 82025 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8812
8813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82025 times.
82025 if(!get_qr(qr_ENEMIESZAXIS))
8814 {
8815 yofs+=8;
8816 yofs+=int32_t(step/zslongToFix(dstep*10));
8817 }
8818 82025 enemy::drawshadow(dest,translucent);
8819 82025 yofs=tempy;
8820 334520 }
8821
8822 1144330 void ePeahat::draw(BITMAP *dest)
8823 {
8824 1144330 update_enemy_frame();
8825 1144330 enemy::draw(dest);
8826 1144330 }
8827
8828 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8829 {
8830 4136 int32_t wpnId = w->id;
8831 4136 int32_t enemyHitWeapon = w->parentitem;
8832
8833
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8834 return 0;
8835
8836
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8837 // fire boomerang, for nailing peahats
8838
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8839 3343 return 0;
8840
8841 // Time for a kludge...
8842 793 int32_t s = superman;
8843 793 superman = 0;
8844 793 int32_t ret = enemy::takehit(w,realweap);
8845 793 superman = s;
8846
8847 // Anyway...
8848
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8849 {
8850 192 clk2=0;
8851 192 movestatus=0;
8852 192 misc=0;
8853 192 clk=0;
8854 192 step=0;
8855 192 }
8856
8857 793 return ret;
8858 4136 }
8859
8860 // auomatically kill off enemy (for rooms with ringleaders)
8861 void ePeahat::kickbucket()
8862 {
8863 hp=-1000; // don't call death_sfx()
8864 }
8865
8866 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8867 3942 {
8868 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8869
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8870 {
8871 2147 misc=-1; //Line of Sight leevers
8872 2147 clk-=16;
8873 2147 }
8874 3942 clk3 = 0;
8875 //nets+1460;
8876 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8877 3942 submerged = false;
8878
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8879 3942 }
8880
8881 923 bool eLeever::isSubmerged() const
8882 {
8883 923 return misc <= 0;
8884 }
8885
8886 1018478 bool eLeever::animate(int32_t index)
8887 {
8888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8889
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8890 {
8891 355 return enemy::animate(index);
8892 }
8893
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8894 31552 return Dead(index);
8895
8896
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8897 {
8898 44970 removearmos(x,y);
8899 44970 }
8900
8901
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8902 {
8903
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8904 {
8905 case 0: //line of sight
8906 case 2:
8907
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8908 {
8909 case -1: //submerged
8910 {
8911
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8912
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8913 {
8914 10261 break;
8915 }
8916
8917 114198 int32_t active=0;
8918
8919
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8920 {
8921
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8922 {
8923 225696 ++active;
8924 225696 }
8925 783342 }
8926
8927
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8928 {
8929 1871 misc=0; //activate this one
8930 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8931 1871 }
8932 }
8933 114198 break;
8934
8935 case 0:
8936 {
8937
8938
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8939 {
8940 misc=1;
8941 clk2=0;
8942 }
8943
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8944 {
8945 57 misc = -1;
8946 57 break;
8947 }
8948 49052 int32_t s=0;
8949
8950
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8951 {
8952
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8953 {
8954 7882 ++s;
8955 7882 }
8956 273250 }
8957
8958
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8959 {
8960 7882 break;
8961 }
8962
8963 41170 int32_t d2=zc_oldrand()&1;
8964
8965
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8966 {
8967 26661 d2+=2;
8968 26661 }
8969
8970
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
8971 {
8972 2111 misc=1;
8973 2111 clk2=0;
8974 2111 clk=0;
8975 2111 }
8976 }
8977 41170 break;
8978
8979 case 1:
8980
8981
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8982
8983 35464 break;
8984
8985 case 2:
8986
8987
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8988
8989 15780 break;
8990
8991 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8992 case 3:
8993
8994
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
8995
8996
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
8997
8998
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
8999 94963 else move(zslongToFix(dstep*100));
9000
9001 95468 break;
9002
9003 case 4:
9004
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9005
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9006 {
9007 468 misc=5;
9008 468 clk=8;
9009 468 }
9010
9011 4365 break;
9012
9013 case 5:
9014
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9015
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9016
9017 6907 break;
9018 } // switch(misc)
9019
9020 337868 break;
9021
9022 default: //random
9023 // step=d->misc3/100.0;
9024
9025 473814 step=zslongToFix(dmisc3*100);
9026
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9027 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9028 {
9029 if (clk2 < 48) clk2+=2;
9030 if (clk2 >= 300) clk2-=2;
9031 }
9032
9033
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9034
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9035
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9036 {
9037 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9038 {
9039 fix_coords();
9040 }*/
9041 289541 misc=3;
9042 289541 step = zslongToFix(dstep*100);
9043 289541 }
9044
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9045
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9046
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9047 {
9048 40151 misc=0;
9049 40151 step=0;
9050 40151 }
9051 274 else clk2=0;
9052
9053
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9054
9055 // variable_walk(d->rate, d->homing, 0);
9056 473814 variable_walk(rate, homing, 0);
9057 473814 } // switch(dmisc1)
9058 811682 }
9059
9060 986571 hxofs=(misc>=2)?0:1000;
9061 986571 return enemy::animate(index);
9062 1018478 }
9063
9064 80892 bool eLeever::canplace(int32_t d2)
9065 {
9066 80892 int32_t nx=HeroX();
9067 80892 int32_t ny=HeroY();
9068
9069
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9070 52400 else nx=TRUNCATE_TILE(nx);
9071
9072
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9073 {
9074 case up:
9075
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9076 14174 break;
9077
9078 case down:
9079
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9080
9081
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9082
9083 14318 break;
9084
9085 case left:
9086
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9087 26181 break;
9088
9089 case right:
9090
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9091
9092
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9093
9094 26219 break;
9095 }
9096
9097
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9098 69464 return false;
9099
9100
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9101
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9102 9317 return false;
9103
9104 2111 x=nx;
9105 2111 y=ny;
9106 2111 dir=d2^1;
9107 2111 return true;
9108 80892 }
9109
9110 1024382 void eLeever::draw(BITMAP *dest)
9111 {
9112 // cs=d->cset;
9113 1024382 cs=dcset;
9114 1024382 update_enemy_frame();
9115
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9116 {
9117
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9118 {
9119 case -1:
9120 case 0:
9121 386939 return;
9122 }
9123 637088 }
9124
9125 637443 enemy::draw(dest);
9126 1024382 }
9127
9128 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9129 998 {
9130 998 hashero=false;
9131 //nets+1000;
9132
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9133 998 }
9134
9135 504762 bool eWallM::animate(int32_t index)
9136 {
9137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9138
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9139 {
9140 return enemy::animate(index);
9141 }
9142
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9143 9856 return Dead(index);
9144
9145
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9146 {
9147 30976 removearmos(x,y);
9148 30976 }
9149
9150 494906 hxofs=1000;
9151
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9152 {
9153
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9154 {
9155 211789 int32_t wall=hero_on_wall();
9156 211789 int32_t wallm_cnt=0;
9157
9158
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9159
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9160 {
9161 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9162
9163
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9164 {
9165 13366 ++wallm_cnt;
9166 13366 }
9167 1013091 }
9168
9169
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9170 {
9171 841 --wall;
9172 841 misc=1; //emerging from the wall?
9173 841 clk2=0;
9174 841 clk3=wall^1;
9175 841 wallm_load_clk=frame;
9176
9177
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9178 {
9179
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9180 91 dir=right;
9181 else
9182 423 dir=left;
9183 514 }
9184 else
9185 {
9186
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9187 66 dir=down;
9188 else
9189 261 dir=up;
9190 }
9191
9192
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9193 {
9194 case up:
9195 231 y=0;
9196 231 break;
9197
9198 case down:
9199 283 y=160;
9200 283 break;
9201
9202 case left:
9203 223 x=0;
9204 223 break;
9205
9206 case right:
9207 104 x=240;
9208 104 break;
9209 }
9210
9211
9212
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9213 {
9214 case up:
9215 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9216 261 flip=wall&1;
9217 261 break;
9218
9219 case down:
9220 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9221 66 flip=((wall&1)^1)+2;
9222 66 break;
9223
9224 case left:
9225 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9226 423 flip=(wall==up?2:0)+1;
9227 423 break;
9228
9229 case right:
9230 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9231 91 flip=(wall==up?2:0);
9232 91 break;
9233 }
9234
9235 841 }
9236 211789 }
9237 377174 }
9238 else
9239 117732 wallm_crawl();
9240
9241 494906 return enemy::animate(index);
9242 504762 }
9243
9244 117732 void eWallM::wallm_crawl()
9245 {
9246 117732 bool w=watch;
9247 117732 hxofs=0;
9248
9249
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9250 {
9251 810 return;
9252 }
9253
9254 // if(dying || watch || (!hashero && stunclk))
9255
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9256 {
9257 14546 return;
9258 }
9259
9260 102376 watch=false;
9261 102376 ++clk2;
9262 // Misc1: slightly different movement
9263 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9264
9265 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9267
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9268 {
9269 4491 --clk2;
9270 4491 }
9271
9272
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9273 {
9274 case 1:
9275 case 2:
9276 52852 zc_swap(dir,clk3);
9277 52852 move(step);
9278 52852 zc_swap(dir,clk3);
9279 52852 break;
9280
9281 case 3:
9282 case 4:
9283 case 5:
9284
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9285 {
9286 4491 watch=w;
9287 4491 return;
9288 }
9289
9290 34905 move(step);
9291 34905 break;
9292
9293 case 6:
9294 case 7:
9295 9984 zc_swap(dir,clk3);
9296 9984 dir^=1;
9297 9984 move(step);
9298 9984 dir^=1;
9299 9984 zc_swap(dir,clk3);
9300 9984 break;
9301
9302 default:
9303 144 misc=0;
9304 144 break;
9305 }
9306
9307 97885 watch=w;
9308 117732 }
9309
9310 9 void eWallM::grabhero()
9311 {
9312 9 hashero=true;
9313 9 superman=1;
9314 9 }
9315
9316 507147 void eWallM::draw(BITMAP *dest)
9317 {
9318 507147 dummy_bool[1]=hashero;
9319 507147 update_enemy_frame();
9320
9321
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9322 {
9323 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9324 129181 }
9325
9326 // enemy::draw(dest);
9327 // tile = clk&8 ? 128:129;
9328 507147 }
9329
9330 bool eWallM::isSubmerged() const
9331 {
9332 return ( !misc );
9333 }
9334
9335 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9336 1640 {
9337
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9338
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9339
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9340 {
9341
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9342 166 }
9343
9344 1640 mainguy=false;
9345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9346 //nets+420;
9347 1640 dummy_int[1]=0;
9348
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9349 1640 }
9350
9351 1042165 bool eTrap::animate(int32_t index)
9352 {
9353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9354
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9355
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9356 21654 return enemy::animate(index);
9357
9358
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9359 {
9360 64549 removearmos(x,y);
9361 64549 }
9362
9363
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9364 {
9365 701302 ox = x;
9366 701302 oy = y;
9367 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9368 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9369
9370
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9371 {
9372 108261 dir=down;
9373 108261 }
9374
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9375 {
9376 259792 dir=right;
9377 259792 }
9378
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9379 {
9380 78523 dir=up;
9381 78523 }
9382 else
9383 {
9384 254726 dir=left;
9385 }
9386
9387 701302 int32_t d2=lined_up(15,true);
9388
9389
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9390
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 173368 times.
405932 ((d2>down) && (dmisc1==2)) ||
9391
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 81901 times.
173368 ((d2>right) && (!dmisc1)) ||
9392
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
268970 ((d2<l_up) && (dmisc1==4)) ||
9393
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 268970 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
125023 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9394
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
268970 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9395 {
9396 2521777 d2=-1;
9397 2521777 }
9398
9399
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 411624 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
432332 if(d2!=-1 && trapmove(d2))
9400 {
9401 2115 dir=d2;
9402 2115 misc=1;
9403 2115 clk2=(dir==down)?3:0;
9404 2115 }
9405 432332 }
9406
9407
2/2
✓ Branch 0 taken 662006 times.
✓ Branch 1 taken 89535 times.
751541 if(misc==1) // charging
9408 {
9409 89535 clk2=(clk2+1)&3;
9410 89535 step=(clk2==3)?1:2;
9411
9412
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9413 {
9414 1909 misc=2;
9415
9416
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9417 {
9418 1909 dir=dir^1;
9419 1909 }
9420 else
9421 {
9422 dir=dir^3;
9423 }
9424 1909 }
9425 else
9426 {
9427 87626 sprite::move(step);
9428 }
9429 89535 }
9430
9431
2/2
✓ Branch 0 taken 517843 times.
✓ Branch 1 taken 233698 times.
751541 if(misc==2) // retreating
9432 {
9433 233698 step=(++clk2&1)?1:0;
9434
9435
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9436 {
9437 case up:
9438
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9439 38739 else sprite::move(step);
9440
9441 38739 break;
9442
9443 case left:
9444
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9445 80555 else sprite::move(step);
9446
9447 80555 break;
9448
9449 case down:
9450
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9451 28905 else sprite::move(step);
9452
9453 28905 break;
9454
9455 case right:
9456
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9457 84176 else sprite::move(step);
9458
9459 84176 break;
9460
9461 case l_up:
9462 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9463 else sprite::move(step);
9464
9465 break;
9466
9467 case r_up:
9468 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9469 else sprite::move(step);
9470
9471 break;
9472
9473 case l_down:
9474 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9475 else sprite::move(step);
9476
9477 break;
9478
9479 case r_down:
9480 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9481 else sprite::move(step);
9482
9483 break;
9484 trap_rest:
9485 {
9486 1323 x=ox;
9487 1323 y=oy;
9488 1323 misc=0;
9489 }
9490 1323 }
9491 233698 }
9492
9493 751541 return enemy::animate(index);
9494 773195 }
9495
9496 110243 bool eTrap::trapmove(int32_t ndir)
9497 {
9498
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9499 {
9500 80479 mapscr* scr = get_scr(screen_spawned);
9501
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9502 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9503
9504 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9505 }
9506
9507
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9508 4730 return false;
9509
9510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9511 return false;
9512
9513
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9514 return false;
9515
9516
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9517 return false;
9518
9519
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9520 4722 return false;
9521
9522
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9523 713 return false;
9524
9525
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9526 return false;
9527
9528
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9529 return false;
9530
9531
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9532 return false;
9533
9534
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9535 return false;
9536
9537 19599 return true;
9538 110243 }
9539
9540 88731 bool eTrap::clip()
9541 {
9542
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9543 {
9544
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9545 {
9546 case up:
9547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9548
9549 5792 break;
9550
9551 case down:
9552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9553
9554 8656 break;
9555
9556 case left:
9557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9558
9559 16039 break;
9560
9561 case right:
9562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9563
9564 15222 break;
9565
9566 case l_up:
9567 if(y<=0||x<=0) return true;
9568
9569 break;
9570
9571 case l_down:
9572 if(y>=world_h-16||x<=0) return true;
9573
9574 break;
9575
9576 case r_up:
9577 if(y<=0||x>=world_w-16) return true;
9578
9579 break;
9580
9581 case r_down:
9582 if(y>=world_h-16||x>=world_w-16) return true;
9583
9584 break;
9585 }
9586
9587 45709 return false;
9588 }
9589 else
9590 {
9591
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9592 {
9593 case up:
9594
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9595
9596 4695 break;
9597
9598 case down:
9599
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9600
9601 5253 break;
9602
9603 case left:
9604
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9605
9606 16376 break;
9607
9608 case right:
9609
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9610
9611 15593 break;
9612
9613 case l_up:
9614 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9615
9616 break;
9617
9618 case l_down:
9619 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9620
9621 break;
9622
9623 case r_up:
9624 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9625
9626 break;
9627
9628 case r_down:
9629 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9630
9631 break;
9632 }
9633
9634 41917 return false;
9635 }
9636 88731 }
9637
9638 1061079 void eTrap::draw(BITMAP *dest)
9639 {
9640 1061079 update_enemy_frame();
9641 1061079 enemy::draw(dest);
9642 1061079 }
9643
9644 5705 int32_t eTrap::takehit(weapon*,weapon*)
9645 {
9646 5705 return 0;
9647 }
9648
9649 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9650 832 {
9651 832 lasthit=-1;
9652 832 lasthitclk=0;
9653 832 mainguy=false;
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9655
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9656
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9657 {
9658
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9659 399 }
9660 else
9661 {
9662
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9663 }
9664
9665
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9666 {
9667
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9668 72 }
9669
9670 //nets+((id==eTRAP_LR)?540:520);
9671 832 dummy_int[1]=0;
9672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9673 832 }
9674
9675 346559 bool eTrap2::animate(int32_t index)
9676 {
9677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9678
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9679
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9680 11026 return enemy::animate(index);
9681
9682
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9683 {
9684 21385 removearmos(x,y);
9685 21385 }
9686
9687
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9688 {
9689
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9690 {
9691 11074 --lasthitclk;
9692 11074 }
9693 else
9694 {
9695 113252 lasthit=-1;
9696 }
9697
9698 124326 bool hitenemy=false;
9699
9700
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9701 {
9702
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9703 {
9704
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9705 {
9706 3669 lasthit=j;
9707 3669 lasthitclk=10;
9708 3669 hitenemy=true;
9709 3669 guys.spr(j)->lasthit=index;
9710 3669 guys.spr(j)->lasthitclk=10;
9711 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9712 3669 }
9713 730351 }
9714 864860 }
9715
9716
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9717 {
9718
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9719 {
9720 3155 lasthit=-1;
9721 3155 lasthitclk=0;
9722 3155 }
9723
9724
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9725 362 sfx(WAV_ZN1TAP,pan(x));
9726
9727 5986 dir=dir^1;
9728 5986 }
9729
9730 124326 sprite::move(step);
9731 124326 }
9732 else
9733 {
9734
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9735 {
9736
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9737 1521 sfx(WAV_ZN1TAP,pan(x));
9738
9739 6919 dir=dir^1;
9740 6919 }
9741
9742 211207 sprite::move(step);
9743 }
9744
9745 335533 return enemy::animate(index);
9746 346559 }
9747
9748 341519 bool eTrap2::trapmove(int32_t ndir)
9749 {
9750 341519 mapscr* scr = get_scr(screen_spawned);
9751
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9752 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9753
9754 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9755 341519 }
9756
9757 328290 bool eTrap2::clip()
9758 {
9759
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9760 {
9761 case up:
9762
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9763
9764 88320 break;
9765
9766 case down:
9767
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9768
9769 89029 break;
9770
9771 case left:
9772
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9773
9774 75153 break;
9775
9776 case right:
9777
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9778
9779 75788 break;
9780 }
9781
9782 328290 return false;
9783 328290 }
9784
9785 350933 void eTrap2::draw(BITMAP *dest)
9786 {
9787 350933 update_enemy_frame();
9788 350933 enemy::draw(dest);
9789 350933 }
9790
9791 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9792 {
9793 3169 return 0;
9794 }
9795
9796 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9797 354 {
9798 //do not show "enemy appering" anim -DD
9799 354 clk=0;
9800 354 mainguy=false;
9801 354 clk2=-14;
9802 //Enemy Editor Size Tab
9803
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9804 //nets+1640;
9805 354 }
9806
9807 354 void eRock::init_size_flags()
9808 {
9809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9810 354 else hxofs = -2;
9811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9812 354 else hyofs = -2;
9813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9814 354 else hit_width = 20;
9815
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9816 354 else hit_height = 20;
9817
9818
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9821
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9822
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9823 {
9824 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9825 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9826 }
9827
9828
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9829 354 }
9830
9831 121997 bool eRock::animate(int32_t index)
9832 {
9833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9834
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9836 return Dead(index);
9837
9838
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9839 {
9840 8376 removearmos(x,y);
9841 8376 }
9842
9843
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9844 {
9845 697 x=zc_oldrand()&0xF0;
9846 697 y=0;
9847 697 clk3=0;
9848 697 clk2=zc_oldrand()&15;
9849 697 }
9850
9851
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9852 {
9853
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9854 {
9855 3430 dir=zc_oldrand()&1;
9856
9857
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9858
9859
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9860 3430 }
9861
9862
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9863 {
9864 95993 x += dir ? 1 : -1; //right, left
9865 95993 dummy_int[1]=dir;
9866
9867
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9868 {
9869 6852 y-=2; //up
9870 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9871 6852 }
9872
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9873 {
9874 10208 y--; //up
9875 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9876 10208 }
9877
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9878 {
9879 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9880 10135 }
9881
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9882 {
9883 10058 y++; //down
9884 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9885 10058 }
9886 else
9887 {
9888 58740 y+=2; //down
9889 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9890 }
9891
9892 95993 ++clk3;
9893 95993 }
9894
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9895 2761 clk3=0; // next bounce
9896 else
9897 423 clk2 = -(zc_oldrand()&63); // back to top
9898 99177 }
9899
9900 121997 return enemy::animate(index);
9901 121997 }
9902
9903 51441 bool eRock::can_drawshadow() const
9904 {
9905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51441 times.
51441 if(shadow_overpit())
9906 return false;
9907
9908 51441 return clk2>=0;
9909 51441 }
9910 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9911 {
9912
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(!can_drawshadow())
9913 7191 return;
9914 44250 int32_t tempy=yofs;
9915 44250 flip = 0;
9916 44250 int32_t fdiv = frate/4;
9917
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9918
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9919 44250 efrate:((clk>=(frate>>1))?1:0);
9920 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9921
9922 44250 yofs+=8;
9923
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9924 44250 sprite::drawshadow(dest, translucent);
9925 44250 yofs=tempy;
9926 51441 }
9927
9928 122078 void eRock::draw(BITMAP *dest)
9929 {
9930
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9931 {
9932 105043 int32_t tempdir=dir;
9933 105043 dir=dummy_int[2];
9934 105043 update_enemy_frame();
9935 105043 enemy::draw(dest);
9936 105043 dir=tempdir;
9937 105043 }
9938 122078 }
9939
9940 1014 int32_t eRock::takehit(weapon*,weapon*)
9941 {
9942 1014 return 0;
9943 }
9944
9945 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9946 30 {
9947 30 clk=0;
9948 30 mainguy=false;
9949 30 clk2=-14;
9950
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9951 //nets+1680;
9952 30 }
9953
9954 4440 bool eBoulder::animate(int32_t index)
9955 {
9956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9957
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9959 return Dead(index);
9960
9961
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9962 {
9963 290 removearmos(x,y);
9964 290 }
9965
9966 zfix *vert;
9967
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9968
9969
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9970 {
9971 32 x=zc_oldrand()&0xF0;
9972 32 y=-32;
9973 32 clk3=0;
9974 32 clk2=zc_oldrand()&15;
9975 32 }
9976
9977
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9978 {
9979
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9980 {
9981 131 dir=zc_oldrand()&1;
9982
9983
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9984
9985
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9986 131 }
9987
9988
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9989 {
9990 3487 x += dir ? 1 : -1; //right, left
9991 3487 dummy_int[1]=dir;
9992
9993
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9994 {
9995 261 y-=2; //up
9996 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9997 261 }
9998
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9999 {
10000 382 y--; //up
10001 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10002 382 }
10003
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10004 {
10005 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10006 376 }
10007
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10008 {
10009 367 y++; //down
10010 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10011 367 }
10012 else
10013 {
10014 2101 y+=2; //down
10015 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10016 }
10017
10018 3487 ++clk3;
10019 3487 }
10020
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10021 101 clk3=0; // next bounce
10022 else
10023 10 clk2 = -(zc_oldrand()&63); // back to top
10024 3598 }
10025
10026 4440 return enemy::animate(index);
10027 4440 }
10028
10029 4440 bool eBoulder::can_drawshadow() const
10030 {
10031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(shadow_overpit())
10032 return false;
10033
10034 4440 return clk2>=0;
10035 4440 }
10036 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10037 {
10038
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(!can_drawshadow())
10039 572 return;
10040 3868 int32_t tempy=yofs;
10041 3868 flip = 0;
10042 3868 int32_t f2=((clk<<2)/frate)<<1;
10043 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10044
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10045
10046 3868 yofs+=8;
10047 3868 xofs-=8;
10048 3868 sprite::drawshadow(dest, translucent);
10049 3868 xofs+=16;
10050 3868 ++shadowtile;
10051 3868 sprite::drawshadow(dest, translucent);
10052 3868 yofs+=16;
10053 3868 shadowtile+=20;
10054 3868 sprite::drawshadow(dest, translucent);
10055 3868 xofs-=16;
10056 3868 --shadowtile;
10057 3868 sprite::drawshadow(dest, translucent);
10058 3868 xofs+=8;
10059 3868 yofs=tempy;
10060 4440 }
10061
10062 4440 void eBoulder::draw(BITMAP *dest)
10063 {
10064
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10065 {
10066 3868 int32_t tempdir=dir;
10067 3868 dir=dummy_int[2];
10068 3868 update_enemy_frame();
10069 3868 dir=tempdir;
10070 3868 xofs-=8;
10071 3868 yofs-=8;
10072 3868 drawblock(dest,15);
10073 3868 xofs+=8;
10074 3868 yofs+=8;
10075 // enemy::draw(dest);
10076 3868 }
10077 4440 }
10078
10079 30 void eBoulder::init_size_flags()
10080 {
10081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10082 30 else hxofs = -10;
10083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10084 30 else hyofs = -10;
10085
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10086 30 else hit_width = 36;
10087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10088 30 else hit_height = 36;
10089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10090 30 else hzsz = 16; //can't be jumped
10091
10092
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10093
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10095
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10096
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10097 {
10098 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10099 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10100 }
10101
10102
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10103 30 }
10104
10105 int32_t eBoulder::takehit(weapon*,weapon*)
10106 {
10107 return 0;
10108 }
10109
10110 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10111
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10112 4429 {
10113 /* fixing
10114 hp=1;
10115 */
10116 4429 mainguy=false;
10117
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10118 4429 hclk=clk; // the "no fire" range
10119 4429 clk=0;
10120 4429 clk3=96;
10121 4429 timer=0;
10122
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10123 {
10124 4415 superman=1;
10125 4415 hxofs=1000;
10126 4415 }
10127
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10128 4429 }
10129
10130 2504746 bool eProjectile::animate(int32_t index)
10131 {
10132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10133
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10134
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10135 {
10136 12326 removearmos(x,y);
10137 12326 }
10138
10139 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10140 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10141
10142
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10143 {
10144 403631 dir=down;
10145 403631 }
10146
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10147 {
10148 916920 dir=right;
10149 916920 }
10150
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10151 {
10152 358900 dir=up;
10153 358900 }
10154 else
10155 {
10156 825295 dir=left;
10157 }
10158
10159
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10160 {
10161
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10162 {
10163
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10164 {
10165 563 unsigned r=zc_oldrand();
10166
10167
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10168 {
10169 6 timer=zc_oldrand()%50+50;
10170 6 }
10171 563 }
10172
10173
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10174 {
10175
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10176 {
10177 119 FireBreath(false);
10178 119 }
10179
10180
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10181 {
10182 6 clk3=0;
10183 6 }
10184 489 }
10185 1046 }
10186
10187 else // Not breath type
10188 {
10189 1197433 unsigned r=zc_oldrand();
10190
10191
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10192 {
10193 17542 FireWeapon();
10194
10195
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10196
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10197 {
10198
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10199 {
10200 909 x-=4;
10201 909 FireWeapon();
10202 909 x+=4;
10203 909 }
10204 14854 }
10205
10206 17542 clk3=0;
10207 17542 }
10208 }
10209 1198479 }
10210
10211 2504746 return enemy::animate(index);
10212 2504746 }
10213
10214 2520335 void eProjectile::draw(BITMAP *dest)
10215 {
10216 2520335 update_enemy_frame();
10217 2520335 enemy::draw(dest);
10218 2520335 }
10219
10220 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10221 533 {
10222 533 hxofs=1000;
10223 533 }
10224
10225 249811 void eTrigger::draw(BITMAP *dest)
10226 {
10227 249811 update_enemy_frame();
10228 249811 enemy::draw(dest);
10229 249811 }
10230
10231 void eTrigger::death_sfx()
10232 {
10233 //silent death
10234 }
10235
10236 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10237 5 {
10238 5 o_tile+=wpnsbuf[iwNPCs].tile;
10239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10240 5 SIZEflags = d->SIZEflags;
10241
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10242 5 }
10243
10244 75 bool eNPC::animate(int32_t index)
10245 {
10246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10247
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10248 70 return Dead(index);
10249
10250
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10251 {
10252 removearmos(x,y);
10253 }
10254
10255
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10256 {
10257 case 0:
10258 {
10259 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10260 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10261
10262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10263 {
10264 dir=down;
10265 }
10266
10267
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10268 {
10269 5 dir=right;
10270 5 }
10271 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10272 {
10273 dir=up;
10274 }
10275 else
10276 {
10277 dir=left;
10278 }
10279 }
10280 5 break;
10281
10282 case 1:
10283 halting_walk(rate, homing, 0, hrate, 48);
10284
10285 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10286 {
10287 newdir(rate, homing, 0);
10288 clk2=48;
10289 ++misc;
10290 }
10291
10292 if(clk2==0)
10293 misc=0;
10294
10295 break;
10296 }
10297
10298 5 return enemy::animate(index);
10299 75 }
10300
10301 75 void eNPC::draw(BITMAP *dest)
10302 {
10303 75 update_enemy_frame();
10304 75 enemy::draw(dest);
10305 75 }
10306
10307 int32_t eNPC::takehit(weapon*,weapon*)
10308 {
10309 return 0;
10310 }
10311
10312 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10313 94 {
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10315 {
10316 94 o_tile=clk;
10317 94 cs=id>>12;
10318 94 }
10319
10320 94 id=id&0xFFF;
10321 94 clk=0;
10322
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10323 94 mainguy=false;
10324 94 SIZEflags = d->SIZEflags;
10325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10326 94 }
10327
10328 81 void eSpinTile::facehero()
10329 {
10330
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10331 {
10332
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10333 1 dir = up;
10334 else
10335 dir = down;
10336 1 }
10337 else
10338 {
10339 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10340 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10341
10342
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10343 {
10344 12 dir=l_down;
10345 12 }
10346
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10347 {
10348 1 dir=down;
10349 1 }
10350
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10351 {
10352 12 dir=r_down;
10353 12 }
10354
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10355 {
10356 6 dir=right;
10357 6 }
10358
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10359 {
10360 17 dir=r_up;
10361 17 }
10362
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10363 {
10364 8 dir=up;
10365 8 }
10366
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10367 {
10368 6 dir=l_up;
10369 6 }
10370 else
10371 {
10372 18 dir=left;
10373 }
10374 }
10375 81 }
10376
10377
10378 15539 bool eSpinTile::animate(int32_t index)
10379 {
10380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10381
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10382
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10383 {
10384 1152 return Dead(index);
10385 }
10386
10387
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10388 {
10389 1241 removearmos(x,y);
10390 1241 }
10391
10392 14387 ++misc;
10393
10394
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10395 {
10396 81 facehero();
10397 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10398 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10399 81 angular=true;
10400 81 angle=ddir;
10401 81 step=zslongToFix(dstep*100);
10402 81 }
10403
10404
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10405 52 kickbucket();
10406
10407 14387 sprite::move(step);
10408 14387 return enemy::animate(index);
10409 15539 }
10410
10411 15457 void eSpinTile::draw(BITMAP *dest)
10412 {
10413 15457 update_enemy_frame();
10414 15457 y-=(misc>>4);
10415 15457 yofs+=2;
10416 15457 enemy::draw(dest);
10417 15457 yofs-=2;
10418 15457 y+=(misc>>4);
10419 15457 }
10420
10421 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10422 {
10423 15457 flip = 0;
10424
1/2
✓ Branch 0 taken 15457 times.
✗ Branch 1 not taken.
15457 if(!can_drawshadow())
10425 15457 return;
10426 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10427 yofs+=4;
10428 enemy::drawshadow(dest, translucent);
10429 yofs-=4;
10430 15457 }
10431
10432 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10433 2797 {
10434 //these are here to bypass compiler warnings about unused arguments
10435 2797 Clk=Clk;
10436 2797 mainguy=false;
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10438
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10439 2797 }
10440
10441 628398 void eZora::facehero()
10442 {
10443
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10444 {
10445 10785 dir=(Hero.y+8<y)?up:down;
10446 10785 }
10447 else
10448 {
10449 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10450 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10451
10452
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10453 {
10454 78554 dir=l_down;
10455 78554 }
10456
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10457 {
10458 45075 dir=down;
10459 45075 }
10460
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10461 {
10462 74214 dir=r_down;
10463 74214 }
10464
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10465 {
10466 115362 dir=right;
10467 115362 }
10468
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10469 {
10470 80403 dir=r_up;
10471 80403 }
10472
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10473 {
10474 41943 dir=up;
10475 41943 }
10476
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10477 {
10478 74672 dir=l_up;
10479 74672 }
10480 else
10481 {
10482 107390 dir=left;
10483 }
10484 }
10485 628398 }
10486
10487 857137 bool eZora::animate(int32_t index)
10488 {
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10490
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10491 2854 return Dead(index);
10492
10493
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10494 {
10495 5746 removearmos(x,y);
10496 5746 }
10497
10498
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10499 {
10500 35 clock_zoras.push_back({screen_spawned, id});
10501 35 return true;
10502 }
10503
10504
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10505 {
10506 628398 facehero();
10507 628398 }
10508
10509
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10510 {
10511 case 0: // reposition him
10512 {
10513 6482 int32_t t=0;
10514 6482 int32_t pos2=zc_oldrand()%160 + 16;
10515 6482 bool placed=false;
10516
10517
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10518 {
10519 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10520 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10521 26366 mapscr* s = get_scr(screen_spawned);
10522
10523 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10524
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10525
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10526
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10527 {
10528 5681 x=sx;
10529 5681 y=sy;
10530
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10531 5681 hxofs=1000; // avoid hit detection
10532 5681 stunclk=0;
10533 5681 placed=true;
10534 5681 }
10535
10536 38464 pos2+=19;
10537
10538
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10539 4563 pos2-=160;
10540
10541 38464 ++t;
10542 }
10543
10544
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10545 65 return true;
10546
10547 }
10548 5681 break;
10549
10550 case 35:
10551
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10552 {
10553 1361 dir=(Hero.y+8<y)?up:down;
10554 1361 }
10555
10556 5232 hxofs=0;
10557 5232 break;
10558
10559 case 35+19:
10560 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10561 4993 sfx(wpnsfx(wpn),pan(x));
10562 4993 break;
10563
10564 case 35+66:
10565 4190 hxofs=1000;
10566 4190 break;
10567
10568 case 198:
10569 2977 clk=-1;
10570 2977 break;
10571 }
10572
10573 853447 return enemy::animate(index);
10574 856401 }
10575
10576 867086 void eZora::draw(BITMAP *dest)
10577 {
10578
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10579 20009 return;
10580
10581 847077 update_enemy_frame();
10582 847077 enemy::draw(dest);
10583 867086 }
10584
10585 867318 bool eZora::isSubmerged() const
10586 {
10587 867318 return clk < 3;
10588 }
10589
10590
3/6
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
100514 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10591 50257 {
10592 50257 multishot= timer = fired = dashing = 0;
10593 50257 hashero = false;
10594 50257 dummy_bool[0]=false;
10595
4/8
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50257 times.
✗ Branch 7 not taken.
50257 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10596
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49255 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50257 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10597 {
10598
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10599
10600
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10601 519 }
10602
10603
3/4
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49255 times.
50257 if(flags & guy_fade_flicker)
10604 {
10605 1002 clk=0;
10606 1002 superman = 1;
10607 1002 fading=fade_flicker;
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10609 1002 dir=down;
10610
10611
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10612
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10613 1002 }
10614
3/4
✓ Branch 0 taken 49255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49122 times.
✓ Branch 3 taken 133 times.
49255 else if(flags & guy_fade_instant)
10615 {
10616 133 clk=0;
10617 133 }
10618
10619
1/2
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
50257 shadowdistance = 0;
10620 50257 clk4 = clk5 = 0;
10621 //nets+2380;
10622
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50255 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50257 if (SIZEflags != 0) init_size_flags();;
10623 50257 }
10624
10625 15823224 bool eStalfos::animate(int32_t index)
10626 {
10627
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15822968 times.
15823224 if(switch_hooked) return enemy::animate(index);
10628
3/4
✓ Branch 0 taken 15822542 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15822542 times.
15822968 if(fallclk||drownclk)
10629 {
10630 426 return enemy::animate(index);
10631 }
10632
2/2
✓ Branch 0 taken 353022 times.
✓ Branch 1 taken 15469520 times.
15822542 if(dying)
10633 {
10634
2/2
✓ Branch 0 taken 352974 times.
✓ Branch 1 taken 48 times.
353022 if(hashero)
10635 {
10636 48 Hero.setEaten(0);
10637 48 hashero=false;
10638 48 }
10639
10640
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316990 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
353022 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10641 {
10642 187 hp=-1000;
10643
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10644 187 Ewpns.add(ew);
10645 187 ew->fakez = fakez;
10646
10647
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10648 {
10649 187 ew->step=0;
10650 187 ew->id=wpn;
10651 187 ew->misc=50;
10652 187 ew->clk=48;
10653 187 }
10654
10655 187 fired=true;
10656 187 }
10657
6/6
✓ Branch 0 taken 156368 times.
✓ Branch 1 taken 196467 times.
✓ Branch 2 taken 130316 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130298 times.
✓ Branch 5 taken 18 times.
352835 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10658 {
10659
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10660 {
10661 1 int32_t wpn2 = wpn+dmisc3;
10662
10663
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10664 {
10665 wpn2=wpn;
10666 }
10667
10668 1 dummy_bool[0]=true;
10669 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10670 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10671 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10672 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10673 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10674 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10675 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10676 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10677 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10678 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10679 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10680 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10681 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10682 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10683 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10684 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10685 1 sfx(wpnsfx(wpn2),pan(x));
10686 1 }
10687 18 }
10688
10689 353022 KillWeapon();
10690 353022 return Dead(index);
10691 }
10692 //vire split
10693 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10694 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10695
13/14
✓ Branch 0 taken 21143 times.
✓ Branch 1 taken 15448377 times.
✓ Branch 2 taken 21143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20792 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14276473 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15469520 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10696 {
10697 1677 stop_bgsfx(index);
10698 1677 int32_t kids = guys.Count();
10699 1677 int32_t id2=dmisc3;
10700
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10701 {
10702
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10703 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10704 3307 }
10705
10706
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10707 {
10708 1 int guycarryingitem = guys.Count()-1;
10709 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10710 1 itemguy = false;
10711 1 }
10712
10713
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10714 {
10715 17 Hero.setEaten(0);
10716 17 hashero=false;
10717 17 }
10718
10719
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10720 323 sfx(deadsfx,pan(x));
10721
10722 1677 return true;
10723 }
10724
10725
2/2
✓ Branch 0 taken 71161 times.
✓ Branch 1 taken 15396682 times.
15467843 if(fading)
10726 {
10727
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69933 times.
71161 if(++clk4 > 60)
10728 {
10729 1228 clk4=0;
10730 1228 superman=0;
10731 1228 fading=0;
10732
10733
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10734 {
10735 //if a custom size (not 16px by 16px)
10736
10737 //if a custom size (not 16px by 16px)
10738
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
967 if (activated_handle && !activated_handle->is_rpos())
10739 removearmos(x,y);
10740 else
10741 {
10742
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10743 {
10744 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10745 for(int32_t dx = 0; dx < tysz; dx ++)
10746 {
10747 for(int32_t dy = 0; dy < tysz; dy++)
10748 {
10749 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10750 did_armos = false;
10751 }
10752 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10753 did_armos = false;
10754 }
10755 for(int32_t dy = 0; dy < tysz; dy ++)
10756 {
10757 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10758 did_armos = false;
10759 }
10760 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10761 }
10762 967 else removearmos(x,y);
10763 }
10764
10765 967 }
10766
10767 1228 clk2=0;
10768
10769 1228 newdir();
10770 1228 }
10771 69933 else return enemy::animate(index);
10772 1228 }
10773
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15248273 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15396682 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10774 9555 removearmos(x,y);
10775
10776
10777
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15390703 times.
15397910 if(hashero)
10778 {
10779 7207 Hero.setX(x);
10780 7207 Hero.setY(y);
10781 7207 ++clk2;
10782
10783
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10784 {
10785
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10786 {
10787 case e7tEATITEMS:
10788 {
10789
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10790 {
10791
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10792 22 game->set_item(i, false);
10793 5632 }
10794
10795 22 break;
10796 }
10797
10798 case e7tEATMAGIC:
10799 game->change_dmagic(-1*game->get_magicdrainrate());
10800 break;
10801
10802 case e7tEATRUPEES:
10803 game->change_drupy(-1);
10804 break;
10805 }
10806
10807 899 clk2=0;
10808 899 }
10809
10810
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10811 6661 --clk;
10812 7207 }
10813
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14341830 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15390703 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10814 {
10815 // Movement engine
10816
6/6
✓ Branch 0 taken 839470 times.
✓ Branch 1 taken 14118397 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14114936 times.
✓ Branch 5 taken 59 times.
14957867 if(clk>=0) switch(id>>12)
10817 {
10818 case 0: // Normal movement
10819
10820 /*
10821 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10822 {
10823 // Overloading clk4 (Tribble clock) here...
10824 step=17/100.0;
10825 if(clk4<32) misc=1;
10826 else if(clk4<48) misc=2;
10827 else if(clk4<300) { misc=3; step = dstep/100.0; }
10828 else if(clk4<316) misc=2;
10829 else if(clk4<412) misc=1;
10830 else if(clk4<540) { misc=0; step=0; }
10831 else clk4=0;
10832 if(clk4==48) clk=0;
10833 hxofs=(misc>=2)?0:1000;
10834 if (dmisc9==e9tLEEVER)
10835 variable_walk(rate, homing, 0);
10836 else
10837 variable_walk_8(rate, homing, 4, 0);
10838 break;
10839 }
10840 */
10841
4/4
✓ Branch 0 taken 13735902 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13318826 times.
14114936 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10842 {
10843 796110 vire_hop();
10844 796110 break;
10845 }
10846
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12334139 times.
13318826 else if(dmisc9==e9tROPE) //Rope charge
10847 {
10848
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10849 {
10850
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10851 {
10852
10853
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10854 {
10855 14 hp=-1000;
10856
10857
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10858 {
10859
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10860 14 Ewpns.add(ew);
10861 14 ew->fakez = fakez;
10862
10863
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10864 {
10865 14 ew->step=0;
10866 14 ew->id=wpn+dmisc3;
10867 14 ew->misc=50;
10868 14 ew->clk=48;
10869 14 }
10870
10871 14 fired=true;
10872 14 }
10873 else
10874 {
10875 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10876 Ewpns.add(ew);
10877 ew->fakez = fakez;
10878
10879 if(wpn==ewSBomb || wpn==ewBomb)
10880 {
10881 ew->step=0;
10882 ew->id=wpn;
10883 ew->misc=50;
10884 ew->clk=48;
10885 }
10886
10887 fired=true;
10888 }
10889 14 }
10890
10891 else
10892 {
10893 33 hp=-1000;
10894
10895 int32_t wpn2;
10896
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10897 33 wpn2=wpn;
10898 else
10899 wpn2=wpn;
10900
10901
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10902 33 Ewpns.add(ew);
10903 33 ew->fakez = fakez;
10904
10905
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10906 {
10907 33 ew->step=0;
10908 33 ew->id=wpn2;
10909 33 ew->misc=50;
10910 33 ew->clk=48;
10911 33 }
10912
10913 33 fired=true;
10914 }
10915 47 }
10916 125869 }
10917
10918 984687 charge_attack();
10919 984687 break;
10920 }
10921 /*
10922 * Boomerang-throwers have a halt count of 1
10923 * Zols have a halt count of (zc_oldrand()&7)<<4
10924 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10925 * Everything else has 48
10926 */
10927 else
10928 {
10929
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11765720 times.
12334139 if(wpn==ewBrang) // Goriya
10930 {
10931 568419 halting_walk(rate,homing,0,hrate, 1);
10932 568419 }
10933
4/4
✓ Branch 0 taken 11616344 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4552225 times.
✓ Branch 3 taken 7064119 times.
11765720 else if(dmisc9==e9tNORMAL && wpn==0)
10934 {
10935
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6346146 times.
7064119 if(dmisc2==e2tSPLITHIT) // Zol
10936 {
10937 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10938 717973 }
10939
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4591991 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6346146 else if(frate<=8 && starting_hp==1) // Gel
10940 {
10941 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10942 215891 }
10943 else // Other
10944 {
10945 6130255 halting_walk(rate,homing,0,hrate, 48);
10946 }
10947 7064119 }
10948 else // Other
10949 {
10950 4701601 halting_walk(rate,homing,0,hrate, 48);
10951 }
10952 }
10953
10954 //if not in midair, and Hero's swinging sword is nearby, jump.
10955 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10956 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10957 {
10958 facehero(false);
10959 sclk=16+((dir^1)<<8);
10960 fall=-FEATHERJUMP;
10961 sfx(WAV_ZN1JUMP,pan(x));
10962 }*/
10963 12334139 break;
10964
10965 // Following cases are for just after creation-by-splitting.
10966 case 1:
10967
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10968 {
10969 821 dir=up;
10970 821 step=8;
10971 821 }
10972
10973
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10974 {
10975 2504 move(step);
10976
10977
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
10978 512 dir=down;
10979 2504 }
10980
10981
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
10982 {
10983
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
10984 503 x+=16;
10985 790 }
10986
10987 3294 ++misc;
10988 3294 break;
10989
10990 case 2:
10991
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10992 {
10993 15 dir=down;
10994 15 step=8;
10995 15 }
10996
10997
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10998 {
10999 45 move(step);
11000 /*
11001 if(!canmove(dir,(zfix)0,0,false))
11002 dir=up;
11003 */
11004 45 }
11005
11006
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11007 {
11008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11009 14 x-=16;
11010 14 }
11011
11012 59 ++misc;
11013 59 break;
11014
11015 default:
11016
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11017 {
11018 28 dir=(zc_oldrand()%4);
11019 28 step=8;
11020 28 }
11021
11022
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11023 {
11024 83 move(step);
11025
11026
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11027 2 dir=dir^1;
11028 83 }
11029
11030
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11031 {
11032
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11033 8 x+=(dir==left ? -16 : 16);
11034 25 }
11035
11036 108 ++misc;
11037 108 break;
11038 14118397 }
11039
11040
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14932595 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14957867 if(id>>12 && misc>=4) //recently spawned by a split enemy
11041 {
11042 829 id&=0xFFF;
11043 829 step = zslongToFix(dstep*100);
11044
11045
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11046
11047
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11048
11049
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11050
11051
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11052
11053 829 misc=3;
11054 829 }
11055 14957867 }
11056 else
11057 {
11058 //sfx(wpnsfx(wpn),pan(x));
11059
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11060 }
11061
11062 // Fire Zol
11063
8/8
✓ Branch 0 taken 6104972 times.
✓ Branch 1 taken 9292938 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965691 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15397910 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11064 {
11065 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11066 1102 sfx(wpnsfx(wpn),pan(x));
11067
11068 1102 int32_t i=Ewpns.Count()-1;
11069 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11070
11071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11072 {
11073 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11074 if ( ew->do_animation ) ew->tile+=ew->aframe;
11075 }
11076 1102 }
11077 // Goriya
11078
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14347935 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15396808 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11079 {
11080 6362 misc=index+100;
11081
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11082 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11083
11084
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11085 {
11086 257 int32_t ndir=dir;
11087
11088
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11089 {
11090 6 ndir=(Hero.y+8<y)?up:down;
11091 6 }
11092 else //turn to face Hero
11093 {
11094 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11095 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11096
11097
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11098 {
11099 13 ndir=down;
11100 13 }
11101
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11102 {
11103 68 ndir=right;
11104 68 }
11105
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11106 {
11107 48 ndir=up;
11108 48 }
11109 else
11110 {
11111 122 ndir=left;
11112 }
11113 }
11114
11115 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11116
11117
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11118 {
11119 223 dir=ndir;
11120 223 }
11121 257 }
11122 6362 }
11123
15/16
✓ Branch 0 taken 15331557 times.
✓ Branch 1 taken 58889 times.
✓ Branch 2 taken 221201 times.
✓ Branch 3 taken 15169245 times.
✓ Branch 4 taken 195083 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170191 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168807 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153707 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153707 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152763 times.
15390446 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11124
3/3
✓ Branch 0 taken 26125 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152763 switch(dmisc1)
11125 {
11126 case e1tCONSTANT: //Deathnut
11127 {
11128 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11129
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11130 {
11131 2583 clk5=0;
11132 2583 fired=false;
11133 2583 }
11134
11135 125732 clk5+=(zc_oldrand()&3);
11136
11137
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11138 {
11139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11140
11141
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11142 {
11143
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11144 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11145 2827 sfx(wpnsfx(wpn),pan(x));
11146 2827 fired=true;
11147 2827 }
11148 51069 }
11149
11150 125732 break;
11151 }
11152
11153 case e1tFIREOCTO: //Fire Octo
11154 906 timer=zc_oldrand()%50+50;
11155 906 break;
11156
11157 default:
11158 26125 FireWeapon();
11159 26125 break;
11160 152763 }
11161
11162 /* Fire again if:
11163 * - clk2 about to run out
11164 * - not already double-firing (dmisc1 is 1)
11165 * - not carrying Hero
11166 * - one in 0xF chance
11167 */
11168
8/10
✓ Branch 0 taken 524941 times.
✓ Branch 1 taken 14872969 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520939 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15397910 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11169 {
11170 #if 1
11171 251 newdir(rate, homing, grumble);
11172 #else
11173 dir^=2;
11174 #endif
11175 251 clk2=28;
11176 251 ++multishot;
11177 251 }
11178
11179
2/2
✓ Branch 0 taken 3492813 times.
✓ Branch 1 taken 11905097 times.
15397910 if(clk2==0)
11180 {
11181 11905097 multishot = 0;
11182 11905097 }
11183
11184
2/2
✓ Branch 0 taken 15333600 times.
✓ Branch 1 taken 64310 times.
15397910 if(timer) //Fire Octo
11185 {
11186 64310 clk2=15; //this keeps the octo in place until he's done firing
11187
11188
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11189 {
11190 15752 FireBreath(false);
11191 15752 }
11192
11193 64310 --timer;
11194 64310 }
11195
11196
2/2
✓ Branch 0 taken 15148517 times.
✓ Branch 1 taken 249393 times.
15397910 if(dmisc2==e2tTRIBBLE)
11197 249393 ++clk4;
11198
11199
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15393430 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15397217 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15397910 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11200 {
11201 693 int32_t kids = guys.Count();
11202 693 int32_t id2=dmisc3;
11203
11204
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11205 {
11206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11207 {
11208
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11209 {
11210 int guycarryingitem = guys.Count()-1;
11211 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11212 itemguy = false;
11213 }
11214
11215 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11216 693 }
11217 693 }
11218
11219
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11220 {
11221 Hero.setEaten(0);
11222 hashero=false;
11223 }
11224
11225 693 stop_bgsfx(index);
11226 693 return true;
11227 }
11228
11229 15397217 return enemy::animate(index);
11230 15823224 }
11231
11232 16245517 void eStalfos::draw(BITMAP *dest)
11233 {
11234 16245517 update_enemy_frame();
11235
11236
7/8
✓ Branch 0 taken 16245091 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16245091 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16158140 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16245517 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11237 {
11238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11239 11115 }
11240
11241 16245517 enemy::draw(dest);
11242 16245517 }
11243
11244 7536565 bool eStalfos::can_drawshadow() const
11245 {
11246 7536565 return enemy::can_drawshadow();
11247 }
11248 7536565 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11249 {
11250 7536565 int32_t tempy=yofs;
11251
11252
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224946 times.
✓ Branch 3 taken 311619 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11253 {
11254 311619 flip = 0;
11255 311619 int32_t fdiv = frate/4;
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11257
11258
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11259 311619 efrate:((clk>=(frate>>1))?1:0);
11260 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11261
11262
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11263 {
11264 311619 shadowtile+=f2;
11265 311619 }
11266 else
11267 {
11268 shadowtile+=f2?1:0;
11269 }
11270
11271 311619 yofs+=shadowdistance;
11272 311619 yofs+=8;
11273 311619 }
11274
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533530 times.
✓ Branch 3 taken 3035 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11275 {
11276 3035 flip = 0;
11277 3035 int32_t fdiv = frate/4;
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11279
11280
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11281 3035 efrate:((clk>=(frate>>1))?1:0);
11282 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11283
11284
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11285 {
11286 3035 shadowtile+=f2;
11287 3035 }
11288 else
11289 {
11290 shadowtile+=f2?1:0;
11291 }
11292 3035 }
11293 7536565 enemy::drawshadow(dest, translucent);
11294 7536565 yofs=tempy;
11295 7536565 }
11296
11297 157815 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11298 {
11299 157815 int32_t wpnId = w->id;
11300 157815 int32_t wpnDir = w->dir;
11301
11302
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156397 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157815 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11303
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11304
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11305 {
11306 265 shield = false;
11307 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11308
11309
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11310 243 o_tile=s_tile;
11311 265 }
11312
11313 157815 int32_t ret = enemy::takehit(w,realweap);
11314
11315
4/4
✓ Branch 0 taken 22327 times.
✓ Branch 1 taken 135488 times.
✓ Branch 2 taken 20576 times.
✓ Branch 3 taken 1751 times.
157815 if(sclk && dmisc2==e2tSPLITHIT)
11316 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11317
11318 157815 return ret;
11319 }
11320
11321 984687 void eStalfos::charge_attack()
11322 {
11323
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11324 6715 return;
11325
11326
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11327 59093 return;
11328
11329
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11330 {
11331 37515 fix_coords(true);
11332
11333
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11334 {
11335 27472 int32_t ldir = lined_up(7,false);
11336
11337
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11338 {
11339 2651 dir=ldir;
11340 2651 dashing=true;
11341
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11342 2651 step=zslongToFix(dstep*100)+1;
11343 else
11344 step=zslongToFix(dmisc10*100);
11345 2651 }
11346 24821 else newdir(4,0,0);
11347 27472 }
11348
11349
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11350 {
11351 1454 step=zslongToFix(dstep*100);
11352 1454 newdir();
11353 1454 dashing=false;
11354 1454 }
11355
11356 37515 zfix div = step;
11357
11358
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11359 div = 1;
11360
11361 37515 clk3=(int32_t)(16.0/div);
11362 37515 return;
11363 }
11364
11365 881364 move(step);
11366 881364 --clk3;
11367 984687 }
11368
11369 796110 void eStalfos::vire_hop()
11370 {
11371
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11372 {
11373
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11374 {
11375
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11376 3843 }
11377 376292 }
11378 417076 else sclk=0;
11379
11380
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11381 31892 return;
11382
11383 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11384 int32_t jump_height;
11385
11386
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11387 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11388 else jump_height = dmisc10;
11389
11390 761476 y=floor_y;
11391
11392
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11393 {
11394 26258 fix_coords();
11395
11396 //z=0;
11397 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11398 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11399
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11400 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11401
11402
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11403 {
11404 //z=0;
11405
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11406 {
11407
11408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11409 17258 }
11410 21336 }
11411
11412
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11413 {
11414 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11415 7030 }
11416
11417 26258 clk3=int32_t(16.0/step.getFloat());
11418 26258 }
11419
11420 761476 --clk3;
11421
11422
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11423 761476 move(step);
11424
11425 761476 floor_y=y;
11426 761476 clk2--;
11427
11428 //if we're in the middle of a jump
11429
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11430 {
11431 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11432
11433
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11434 {
11435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11436 93147 else z=h;
11437 93147 }
11438 else
11439 {
11440 384731 y=floor_y-h;
11441 384731 shadowdistance=h;
11442 }
11443 477878 }
11444 else
11445 283598 shadowdistance = 0;
11446 796110 }
11447
11448 138 void eStalfos::eathero()
11449 {
11450
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11451 {
11452 70 hashero=true;
11453 70 y=floor_y;
11454 70 z=0;
11455
11456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11457 {
11458 Hero.setX(x);
11459 Hero.setY(y);
11460 }
11461 else
11462 {
11463 70 x=Hero.getX();
11464 70 y=Hero.getY();
11465 }
11466
11467 70 clk2=0;
11468 70 }
11469 138 }
11470
11471 1469390 bool eStalfos::WeaponOut()
11472 {
11473
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11474 {
11475
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11476 {
11477 846991 return true;
11478 }
11479 1553588 }
11480
11481 622399 return false;
11482 1469390 }
11483
11484 353022 void eStalfos::KillWeapon()
11485 {
11486
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 353022 times.
646406 for(int32_t i=0; i<Ewpns.Count(); i++)
11487 {
11488
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11489 {
11490 //only kill this Goriya's boomerang -DD
11491
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11492 {
11493 411 Ewpns.del(i);
11494 411 }
11495 810 }
11496 293384 }
11497 353022 }
11498
11499 void eStalfos::break_shield()
11500 {
11501 if(!shield)
11502 return;
11503
11504 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11505 shield=false;
11506
11507 if(get_qr(qr_BRKNSHLDTILES))
11508 o_tile=s_tile;
11509 }
11510
11511 void eStalfos::repair_shield()
11512 {
11513 if (shield)
11514 return;
11515
11516 shield = true;
11517
11518 if (get_qr(qr_BRKNSHLDTILES))
11519 {
11520 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11521 else o_tile = d->tile;
11522 }
11523 }
11524
11525 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11526 13720 {
11527
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11528
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11529 13720 movestatus=1;
11530
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11531 {
11532 step = dmisc19/100.0;
11533 movestatus = 1;
11534 }
11535
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11536 13720 c=0;
11537 13720 clk4=0;
11538 //nets;
11539
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11540 13720 dummy_int[1]=0;
11541 13720 }
11542
11543 3535341 bool eKeese::animate(int32_t index)
11544 {
11545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11546
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11547
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11548 124509 return Dead(index);
11549
11550
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11551 {
11552 26191 removearmos(x,y);
11553 26191 }
11554
11555
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11556 {
11557 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11558 1025042 }
11559 else
11560 {
11561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11562 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11563 }
11564
11565
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11566 {
11567
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11568 {
11569
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11570 {
11571 105 int32_t kids = guys.Count();
11572 105 bool success = false;
11573 105 int32_t id2=dmisc3;
11574 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11575
11576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11577 {
11578
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11579 {
11580 int guycarryingitem = guys.Count()-1;
11581 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11582 itemguy = false;
11583 }
11584
11585 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11586 105 }
11587
11588 105 stop_bgsfx(index);
11589 105 return true;
11590 }
11591 else
11592 {
11593 86 clk4=0;
11594 }
11595 86 }
11596 120233 }
11597 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11598
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11599 {
11600
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11601 {
11602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11603 {
11604 fakez=int32_t(step/zslongToFix(dstep*100));
11605 // Some variance in keese flight heights when away from Hero
11606 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11607
11608 }
11609 else
11610 {
11611 687068 z=int32_t(step/zslongToFix(dstep*100));
11612 // Some variance in keese flight heights when away from Hero
11613
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11614 }
11615 687068 }
11616 else
11617 {
11618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11619 {
11620 fakez=int32_t(step/zslongToFix(dstep*100));
11621 // Some variance in keese flight heights when away from Hero
11622 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11623
11624 }
11625 else
11626 {
11627 158811 z=int32_t(step/zslongToFix(dstep*100));
11628 // Some variance in keese flight heights when away from Hero
11629
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11630 }
11631 }
11632 845879 }
11633
11634 3410727 return enemy::animate(index);
11635 3535341 }
11636
11637 2640415 bool eKeese::can_drawshadow() const
11638 {
11639
4/4
✓ Branch 0 taken 1242697 times.
✓ Branch 1 taken 1397718 times.
✓ Branch 2 taken 15437 times.
✓ Branch 3 taken 1227260 times.
2640415 if(get_qr(qr_ENEMIESZAXIS) && step <= 0)
11640 15437 return false;
11641
11642 2624978 return enemy::can_drawshadow();
11643 2640415 }
11644 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11645 {
11646 2088281 flip = 0;
11647
2/2
✓ Branch 0 taken 1536147 times.
✓ Branch 1 taken 552134 times.
2088281 if(!can_drawshadow())
11648 1536147 return;
11649 552134 int32_t tempy=yofs;
11650 552134 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11651
11652
2/2
✓ Branch 0 taken 113825 times.
✓ Branch 1 taken 438309 times.
552134 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552134 times.
552134 if(!get_qr(qr_ENEMIESZAXIS))
11654 {
11655 yofs+=int32_t(step/zslongToFix(dstep*10));
11656 }
11657
11658 552134 enemy::drawshadow(dest, translucent);
11659 552134 yofs=tempy;
11660 2088281 }
11661
11662 7949863 void eKeese::draw(BITMAP *dest)
11663 {
11664 7949863 update_enemy_frame();
11665 7949863 enemy::draw(dest);
11666 7949863 }
11667
11668 13720 void eKeese::init_size_flags()
11669 {
11670 13720 SIZEflags = d->SIZEflags;
11671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11672
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11673
11674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11676
11677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11678
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11679
11680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11681
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11682
11683
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11684 // al_trace("Enemy txsz:%i\n", txsz);
11685
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11686
11687
11688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11689
11690
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11691
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11692 {
11693 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11694 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11695 }
11696
11697
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11698 13720 }
11699
11700 20171 void eWizzrobe::submerge(bool set)
11701 {
11702
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11703 {
11704 20024 hxofs = set?1000:0;
11705 20024 return;
11706 }
11707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11708 147 submerged = set;
11709
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11710 76 hxofs+=1000;
11711 71 else hxofs -= 1000;
11712 20171 }
11713 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11714 5350 {
11715 5350 hxofs = 0;
11716 5350 submerged = false;
11717
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11718 {
11719 case 0:
11720 2992 submerge(true);
11721 2992 fading=fade_invisible;
11722 // Set clk to just before the 'reappear' threshold
11723
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11724 2992 break;
11725
11726 default:
11727 2358 dir=(loadside==right)?right:left;
11728 2358 misc=-3;
11729 2358 break;
11730 }
11731
11732 //netst+2880;
11733 5350 charging=false;
11734 5350 firing=false;
11735 5350 fclk=0;
11736
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11737
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11738 5350 }
11739
11740 2081613 bool eWizzrobe::animate(int32_t index)
11741 {
11742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11743
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11744
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11745 {
11746 38023 return Dead(index);
11747 }
11748
11749
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11750 {
11751 66646 removearmos(x,y);
11752 66646 }
11753
11754
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11755 {
11756 1019220 wizzrobe_attack();
11757 1019220 }
11758 else // Teleporting
11759 {
11760
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11761 {
11762 7084 fading=0;
11763 7084 submerge(false);
11764 7084 solid_update(false);
11765 7084 }
11766
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11767 {
11768 case 0:
11769
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11770 {
11771 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11772 // but should not appear on dungeon walls.
11773
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11774
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11775 {
11776 //2.10 Windrobe
11777 //randomise location and face Hero
11778 224 int32_t t=0;
11779 224 bool placed=false;
11780
11781
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11782 {
11783
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11784 {
11785 280 x=((zc_oldrand()%12)+2)*16;
11786 280 y=((zc_oldrand()%7)+2)*16;
11787 280 }
11788 else
11789 {
11790 87 x=((zc_oldrand()%14)+1)*16;
11791 87 y=((zc_oldrand()%9)+1)*16;
11792 }
11793
11794 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11795
11796
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11797 {
11798 224 placed=true;
11799 224 }
11800
11801 367 ++t;
11802 }
11803
11804
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11805 {
11806
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11807 {
11808 47 dir=down;
11809 47 }
11810 else
11811 {
11812 14 dir=up;
11813 }
11814 61 }
11815 else
11816 {
11817
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11818 {
11819 72 dir=right;
11820 72 }
11821 else
11822 {
11823 91 dir=left;
11824 }
11825 }
11826
11827
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11828 return true;
11829
11830
11831 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11832 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11833 224 }
11834 4486 else place_on_axis(true, dmisc4!=0);
11835 5123 }
11836 else
11837 {
11838 1117 int32_t t=0;
11839 1117 bool placed=false;
11840
11841
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11842 {
11843
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11844 {
11845 1340 x=((zc_oldrand()%12)+2)*16;
11846 1340 y=((zc_oldrand()%7)+2)*16;
11847 1340 }
11848 else
11849 {
11850 1103 x=((zc_oldrand()%14)+1)*16;
11851 1103 y=((zc_oldrand()%9)+1)*16;
11852 }
11853
11854 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11855
11856
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11857 {
11858 1117 placed=true;
11859 1117 }
11860
11861 2443 ++t;
11862 }
11863
11864
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11865 {
11866
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11867 {
11868 238 dir=down;
11869 238 }
11870 else
11871 {
11872 148 dir=up;
11873 }
11874 386 }
11875 else
11876 {
11877
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11878 {
11879 340 dir=right;
11880 340 }
11881 else
11882 {
11883 391 dir=left;
11884 }
11885 }
11886
11887
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11888 return true;
11889 }
11890
11891 6240 fading=fade_flicker;
11892 6240 submerge(false);
11893 6240 solid_update(false);
11894 6240 break;
11895
11896 case 64:
11897 5313 fading=0;
11898 5313 charging=true;
11899 5313 break;
11900
11901 case 73:
11902 5151 charging=false;
11903 5151 firing=40;
11904 5151 break;
11905
11906 case 83:
11907 5006 wizzrobe_attack_for_real();
11908 5006 break;
11909
11910 case 119:
11911 4247 firing=false;
11912 4247 charging=true;
11913 4247 break;
11914
11915 case 128:
11916 4109 fading=fade_flicker;
11917 4109 charging=false;
11918 4109 break;
11919
11920 case 146:
11921 3855 fading=fade_invisible;
11922 3855 submerge(true);
11923 3855 solid_update(false);
11924
11925 [[fallthrough]];
11926 default:
11927
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11928 6249 clk=-1;
11929
11930 987220 break;
11931 }
11932 }
11933
11934 2043590 return enemy::animate(index);
11935 2081613 }
11936
11937 7929 void eWizzrobe::wizzrobe_attack_for_real()
11938 {
11939
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11940 return;
11941
11942
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11943 {
11944 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11945 5946 sfx(firesfx, pan(x));
11946 5946 }
11947
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11948 {
11949 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11950 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11951 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11952 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11953 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11954 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11955 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11956 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11957 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11958 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11959 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11960 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11961 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11962 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11963 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11964 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11965 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11966 //i've compromised by making all old quest use this code chunk by default.
11967
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11968 {
11969 995 sfx(WAV_FIRE, pan(x));
11970
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11971 else
11972 {
11973
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11974 {
11975 19 case ewFireball: sfx(40, pan(x)); break;
11976 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11977 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11978 case ewRock: sfx(51, pan(x)); break;
11979 68 case ewMagic: sfx(32, pan(x)); break;
11980 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11981 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11982 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11983 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11984 case ewFireTrail: sfx(13, pan(x)); break;
11985 420 case ewFlame: sfx(13, pan(x)); break;
11986 case ewWind: sfx(32, pan(x)); break;
11987 case ewFlame2: sfx(13, pan(x)); break;
11988 case ewFlame2Trail: sfx(13, pan(x)); break;
11989 case ewIce: sfx(44, pan(x)); break;
11990 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
11991 default: sfx(WAV_FIRE, pan(x)); break;
11992 }
11993 }
11994 995 }
11995 else
11996 {
11997 sfx(firesfx, pan(x));
11998 }
11999 995 }
12000
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12001 {
12002 971 int32_t bc=0;
12003
12004
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12005 {
12006
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12007 {
12008 5195 ++bc;
12009 5195 }
12010 10497 }
12011
12012
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12013 {
12014 963 int32_t kids = guys.Count();
12015 963 int32_t bats=(zc_oldrand()%3)+1;
12016
12017
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12018 {
12019 // Summon bats (or anything)
12020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12021 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12022 1965 }
12023 963 sfx(firesfx, pan(x));
12024 963 }
12025 971 }
12026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12027 {
12028
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12029 {
12030 return;
12031 }
12032
12033 17 int32_t kids = guys.Count();
12034
12035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12036 {
12037 17 int32_t newguys=(zc_oldrand()%3)+1;
12038 17 bool summoned=false;
12039
12040
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12041 {
12042 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12043 32 int32_t x2=0;
12044 32 int32_t y2=0;
12045
12046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12047 {
12048 36 x2=16*((zc_oldrand()%12)+2);
12049 36 y2=16*((zc_oldrand()%7)+2);
12050
12051
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12052 {
12053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12054 {
12055 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12056
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12057 {
12058 ((enemy*)guys.spr(kids+i))->fakez = 64;
12059 ((enemy*)guys.spr(kids+i))->z = 0;
12060 }
12061 32 }
12062
12063 32 summoned=true;
12064 32 break;
12065 }
12066 4 }
12067 32 }
12068
12069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12070 {
12071 17 sfx(firesfx, pan(x));
12072 17 }
12073 17 }
12074 17 }
12075 7929 }
12076
12077
12078 1019220 void eWizzrobe::wizzrobe_attack()
12079 {
12080
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12081 86341 return;
12082
12083
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12084 {
12085 39538 fix_coords();
12086
12087
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12088 {
12089 case 1: //walking
12090
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12091 2644 misc=0;
12092 else
12093 {
12094 10364 clk3=16;
12095
12096
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12097 {
12098 1398 wizzrobe_newdir(0);
12099 1398 }
12100 }
12101
12102 13008 break;
12103
12104 case 2: //phasing
12105 {
12106 3903 int32_t jx=x;
12107 3903 int32_t jy=y;
12108 3903 int32_t jdir=-1;
12109
12110
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12111 {
12112 case 0:
12113 484 jx-=32;
12114 484 jy-=32;
12115 484 jdir=15;
12116 484 break;
12117
12118 case 1:
12119 472 jx+=32;
12120 472 jy-=32;
12121 472 jdir=9;
12122 472 break;
12123
12124 case 2:
12125 482 jx+=32;
12126 482 jy+=32;
12127 482 jdir=11;
12128 482 break;
12129
12130 case 3:
12131 492 jx-=32;
12132 492 jy+=32;
12133 492 jdir=13;
12134 492 break;
12135 }
12136
12137
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12138 {
12139 1140 misc=3;
12140 1140 clk3=32;
12141 1140 dir=jdir;
12142 1140 break;
12143 }
12144 2763 }
12145 [[fallthrough]];
12146 case 3:
12147 3813 dir&=3;
12148 3813 misc=0;
12149 [[fallthrough]];
12150 case 0:
12151 19894 wizzrobe_newdir(64);
12152 [[fallthrough]];
12153 default:
12154
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12155 {
12156
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12157 {
12158 3265 misc=1;
12159 3265 clk3=16;
12160 3265 }
12161 else
12162 {
12163 239 wizzrobe_newdir(64);
12164 239 misc=0;
12165 239 clk3=32;
12166 }
12167 3504 }
12168 else
12169 {
12170 21886 clk3=32;
12171 }
12172
12173 25390 break;
12174 }
12175
12176
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12177 4478 ++misc;
12178 39538 }
12179
12180 932879 --clk3;
12181
12182
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12183 {
12184 case 1:
12185 case 3:
12186 248377 step=1;
12187 248377 break;
12188
12189 case 2:
12190 63903 step=0;
12191 63903 break;
12192
12193 default:
12194 620599 step=0.5;
12195 620599 break;
12196
12197 }
12198
12199 932879 move(step);
12200
12201 // if(d->misc1 && misc<=0 && clk3==28)
12202
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12203 {
12204
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12205 {
12206
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12207 {
12208 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12209 // sfx(WAV_WAND,pan(x));
12210 1928 wizzrobe_attack_for_real();
12211 1928 fclk=30;
12212 1928 }
12213 16835 }
12214 else
12215 {
12216
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12217 {
12218 995 wizzrobe_attack_for_real();
12219 995 fclk=30;
12220 995 }
12221 }
12222 21547 }
12223
12224
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12225 4050 misc=2;
12226
12227
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12228 3441 fix_coords();
12229
12230
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12231 {
12232
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12233 {
12234 83282 --fclk;
12235 83282 }
12236 932879 }
12237
12238 1019220 }
12239
12240 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12241 {
12242 // Wizzrobes shouldn't move to the edge of the screen;
12243 // if they're already there, they should move toward the center
12244
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12245 33 dir=right;
12246
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12247 4 dir=left;
12248
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12249 2 dir=down;
12250
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12251 5 dir=up;
12252 else
12253 21487 newdir(4,homing,spw_wizzrobe);
12254 21531 }
12255
12256 2099229 void eWizzrobe::draw(BITMAP *dest)
12257 {
12258 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12259
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12260 125018 return;
12261
12262 1974211 int32_t tempint=dummy_int[1];
12263 1974211 bool tempbool1=dummy_bool[1];
12264 1974211 bool tempbool2=dummy_bool[2];
12265 1974211 dummy_int[1]=fclk;
12266 1974211 dummy_bool[1]=charging;
12267 1974211 dummy_bool[2]=firing;
12268 1974211 update_enemy_frame();
12269 1974211 dummy_int[1]=tempint;
12270 1974211 dummy_bool[1]=tempbool1;
12271 1974211 dummy_bool[2]=tempbool2;
12272 1974211 enemy::draw(dest);
12273 2099229 }
12274
12275 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12276 203 {
12277 203 fading=fade_flash_die;
12278
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12279 {
12280 3 dir=up;
12281 3 }
12282
12283
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12284 {
12285 dir=left;
12286 }
12287
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12288 203 }
12289
12290 125855 bool eDodongo::animate(int32_t index)
12291 {
12292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12293
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12294 {
12295 3790 return Dead(index);
12296 }
12297
12298
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12299 {
12300 569 removearmos(x,y);
12301 569 }
12302
12303
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12304 {
12305
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12306 113 hp-=misc; // store bomb's power in misc
12307 10848 }
12308 else
12309 111217 constant_walk(rate,homing,spw_clipright);
12310
12311 122065 hit_width = (dir<=down) ? 16 : 32;
12312 // hysz = (dir>=left) ? 16 : 32;
12313
12314 122065 return enemy::animate(index);
12315 125855 }
12316
12317 125845 void eDodongo::draw(BITMAP *dest)
12318 {
12319 125845 tile=o_tile;
12320
12321
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12322 {
12323 3065 enemy::drawzcboss(dest);
12324 3065 return;
12325 }
12326
12327 122780 update_enemy_frame();
12328 122780 enemy::drawzcboss(dest);
12329
12330
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12331 {
12332 71118 tile+=dummy_int[1]; //second tile is previous tile
12333 71118 xofs-=16; //new xofs change
12334 71118 enemy::drawzcboss(dest);
12335 71118 xofs+=16;
12336 71118 }
12337
12338 125845 }
12339
12340 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12341 {
12342 8218 int32_t wpnId = w->id;
12343 8218 int32_t power = w->power;
12344 8218 int32_t wpnx = w->x;
12345 8218 int32_t wpny = w->y;
12346
12347
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12348 5761 return 0;
12349
12350
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12351 {
12352 case wPhantom:
12353 return 0;
12354
12355 case wFire:
12356 case wBait:
12357 case wWhistle:
12358 case wWind:
12359 case wSSparkle:
12360 case wFSparkle:
12361 return 0;
12362
12363 case wLitBomb:
12364 case wLitSBomb:
12365
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12366 690 return 0;
12367
12368 113 clk2=96;
12369 113 misc=power;
12370
12371
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12372 3 item_set=isSBOMB100;
12373
12374 113 return 1;
12375
12376 case wBomb:
12377 case wSBomb:
12378
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12379 516 return 0;
12380
12381 975 stunclk=160;
12382 975 misc=wpnId; // store wpnId
12383 975 return 1;
12384
12385 case wSword:
12386
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12387 {
12388 88 sfx(WAV_EHIT,pan(x));
12389 88 hp=0;
12390 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12391 88 fading=0; // don't flash
12392 88 return 1;
12393 }
12394
12395 [[fallthrough]];
12396 default:
12397 75 sfx(WAV_CHINK,pan(x));
12398 75 }
12399
12400 75 return 1;
12401 8218 }
12402
12403 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12404 48 {
12405 48 fading=fade_flash_die;
12406 //nets+5180;
12407 48 previous_dir=-1;
12408
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12409 {
12410 1 dir=up;
12411 1 }
12412
12413
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12414 {
12415 dir=left;
12416 }
12417
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12418 48 }
12419
12420 39398 bool eDodongo2::animate(int32_t index)
12421 {
12422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12423
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12424 {
12425 1158 return Dead(index);
12426 }
12427
12428
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12429 {
12430 167 removearmos(x,y);
12431 167 }
12432
12433
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12434 {
12435
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12436 42 hp-=misc; // store bomb's power in misc
12437 4032 }
12438 else
12439 34208 constant_walk(rate,homing,spw_clipbottomright);
12440
12441 38240 hit_width = (dir<=down) ? 16 : 32;
12442 38240 hit_height = (dir>=left) ? 16 : 32;
12443 38240 hxofs=(dir>=left)?-8:0;
12444 38240 hyofs=(dir<left)?-8:0;
12445
12446 38240 return enemy::animate(index);
12447 39398 }
12448
12449 39601 void eDodongo2::draw(BITMAP *dest)
12450 {
12451
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12452 {
12453 768 enemy::drawzcboss(dest);
12454 768 return;
12455 }
12456
12457 38833 int32_t tempx=xofs;
12458 38833 int32_t tempy=yofs;
12459 38833 update_enemy_frame();
12460 38833 enemy::drawzcboss(dest);
12461 38833 tile+=dummy_int[1]; //second tile change
12462 38833 xofs+=dummy_int[2]; //new xofs change
12463 38833 yofs+=dummy_int[3]; //new yofs change
12464 38833 enemy::drawzcboss(dest);
12465 38833 xofs=tempx;
12466 38833 yofs=tempy;
12467 39601 }
12468
12469 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12470 {
12471 3929 int32_t wpnId = w->id;
12472 3929 int32_t power = w->power;
12473 3929 int32_t wpnx = w->x;
12474 3929 int32_t wpny = w->y;
12475
12476
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12477 2377 return 0;
12478
12479
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12480 {
12481 case wPhantom:
12482 return 0;
12483
12484 case wFire:
12485 case wBait:
12486 case wWhistle:
12487 case wWind:
12488 case wSSparkle:
12489 case wFSparkle:
12490 346 return 0;
12491
12492 case wLitBomb:
12493 case wLitSBomb:
12494
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12495 {
12496 case up:
12497
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12498 77 return 0;
12499
12500 4 break;
12501
12502 case down:
12503
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12504 71 return 0;
12505
12506 6 break;
12507
12508 case left:
12509
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12510 66 return 0;
12511
12512 16 break;
12513
12514 case right:
12515
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12516 65 return 0;
12517
12518 16 break;
12519 }
12520
12521 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12522 // return 0;
12523 42 clk2=96;
12524 42 misc=power;
12525
12526
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12527 item_set=isSBOMB100;
12528
12529 42 return 1;
12530
12531 case wBomb:
12532 case wSBomb:
12533
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12534 {
12535 case up:
12536
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12537 84 return 0;
12538
12539 92 break;
12540
12541 case down:
12542
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12543 113 return 0;
12544
12545 55 break;
12546
12547 case left:
12548
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12549 80 return 0;
12550
12551 105 break;
12552
12553 case right:
12554
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12555 71 return 0;
12556
12557 93 break;
12558 }
12559
12560 345 stunclk=160;
12561 345 misc=wpnId; // store wpnId
12562 345 return 1;
12563
12564 case wSword:
12565
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12566 {
12567 34 sfx(WAV_EHIT,pan(x));
12568 34 hp=0;
12569 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12570 34 fading=0; // don't flash
12571 34 return 1;
12572 }
12573
12574 [[fallthrough]];
12575 default:
12576 158 sfx(WAV_CHINK,pan(x));
12577 158 }
12578
12579 158 return 1;
12580 3929 }
12581
12582 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12583 126 {
12584 //these are here to bypass compiler warnings about unused arguments
12585
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12586 {
12587
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12588 126 }
12589 else { x = X; y = Y; }
12590
12591 //nets+5940;
12592
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12593 {
12594 81 }
12595 else
12596 {
12597
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12598 {
12599 7 flip=1;
12600 7 }
12601 }
12602
12603
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12604 126 clk3=32;
12605 126 clk2=0;
12606 126 clk4=clk;
12607 126 dir=left;
12608
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12609 126 }
12610
12611 71899 bool eAquamentus::animate(int32_t index)
12612 {
12613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12614
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12615 2092 return Dead(index);
12616
12617 // fbx=x+((id==eRAQUAM)?4:-4);
12618
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12619 {
12620 317 removearmos(x,y);
12621 317 }
12622
12623 69807 fbx=x;
12624
12625 /*
12626 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12627 {
12628 fbx+=16;
12629 }
12630 */
12631
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12632 {
12633 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12634 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12635 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12636 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12637 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12638 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12639 450 sfx(wpnsfx(wpn),pan(x));
12640 450 }
12641
12642
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12643 {
12644 345 clk3=32;
12645 345 }
12646
12647 69807 int screen_x = x.getInt()%256;
12648
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12649 {
12650 1117 int32_t d2=(zc_oldrand()%3)+1;
12651
12652
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12653 {
12654 752 dir=d2;
12655 752 }
12656
12657
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12658 {
12659
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12660 {
12661 38 dir=right;
12662 38 }
12663
12664
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12665 {
12666 dir=left;
12667 }
12668 385 }
12669 else
12670 {
12671
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12672 {
12673 21 dir=right;
12674 21 }
12675
12676
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12677 {
12678 34 dir=left;
12679 34 }
12680 }
12681 1117 }
12682
12683
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12684 {
12685
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12686 {
12687 4546 x-=1;
12688 4546 }
12689 else
12690 {
12691 3995 x+=1;
12692 }
12693 8541 }
12694
12695 69807 clk4=(clk4+1)%256;
12696
12697 69807 return enemy::animate(index);
12698 71899 }
12699
12700 72310 void eAquamentus::draw(BITMAP *dest)
12701 {
12702
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12703 {
12704 44994 xofs=(dmisc1?-16:0);
12705
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12706
12707
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12708 {
12709 1312 xofs=0;
12710 1312 enemy::draw(dest);
12711 1312 }
12712 else
12713 {
12714 43682 drawblock(dest,15);
12715 }
12716 44994 }
12717 else
12718 {
12719 27316 int32_t xblockofs=((dmisc1)?-16:16);
12720 27316 xofs=0;
12721
12722
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12723 {
12724 1462 enemy::draw(dest);
12725 1462 return;
12726 }
12727
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12728 {
12729 // face (0=firing, 2=resting)
12730 25854 tile=o_tile+((clk3>0)?0:2);
12731 25854 enemy::draw(dest);
12732 // tail (
12733 25854 tile=o_tile+((clk&16)?1:3);
12734 25854 xofs=xblockofs;
12735 25854 enemy::draw(dest);
12736 // body
12737 25854 yofs+=16;
12738 25854 xofs=0;
12739 25854 tile=o_tile+((clk&16)?20:22);
12740 25854 enemy::draw(dest);
12741 25854 xofs=xblockofs;
12742 25854 tile=o_tile+((clk&16)?21:23);
12743 25854 enemy::draw(dest);
12744 25854 yofs-=16;
12745 25854 }
12746 else enemy::draw(dest);
12747 }
12748 72310 }
12749
12750 23834 bool eAquamentus::hit(weapon *w)
12751 {
12752
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12753
12754
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12755 {
12756 case wBeam:
12757 case wRefBeam:
12758 case wMagic:
12759 4201 hit_height=32;
12760 4201 }
12761
12762
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12763 23834 hit_height=16;
12764 23834 return ret;
12765
12766 23834 }
12767
12768 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12769 93 {
12770
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12771 {
12772
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12773 93 }
12774 else { x = X; y = Y; }
12775
12776 93 Clk=Clk;
12777
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12778 {
12779 clk=0;
12780 superman = 1;
12781 fading=fade_flicker;
12782 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12783 }
12784
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12785 {
12786 42 clk=0;
12787 42 }
12788 93 hxofs=-16;
12789 93 hit_width=48;
12790 93 clk4=0;
12791
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12792
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12794
12795 //nets+5340;
12796 93 }
12797
12798 70891 bool eGohma::animate(int32_t index)
12799 {
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12801
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12802 1226 return Dead(index);
12803
12804
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12805 {
12806
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12807 {
12808 35 clk4=0;
12809 35 superman=0;
12810 35 fading=0;
12811 35 clk=0;
12812
12813 35 }
12814 1 else return enemy::animate(index);
12815 35 }
12816
12817
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12818 {
12819
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 if (activated_handle && !activated_handle->is_rpos()) removearmos(x,y);
12820 else
12821 {
12822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12823 350 did_armos = false;
12824 350 removearmos(x,y);
12825 350 did_armos = false;
12826
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12827 }
12828 350 }
12829
12830
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12831
12832 // Movement clk must be separate from animation clk because of the Clock item
12833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12834 68878 clk4++;
12835
12836
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12837 {
12838
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12839 546 dir^=1;
12840 else
12841 486 dir=zc_oldrand()%3+1;
12842 1032 }
12843
12844
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12845 {
12846
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12847 {
12848 case 1:
12849 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12850 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12851 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12852 235 sfx(wpnsfx(wpn),pan(x));
12853 235 break;
12854
12855 default:
12856
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12857 {
12858 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12859 754 sfx(wpnsfx(wpn),pan(x));
12860 754 sfx(wpnsfx(wpn),pan(x));
12861 754 }
12862
12863 882 break;
12864 }
12865 1117 }
12866
12867
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12868 {
12869
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12870 {
12871 290 FireBreath(true);
12872 290 }
12873 2215 }
12874
12875
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12876 34479 move((zfix)1);
12877
12878
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12879 150 clk3=0;
12880
12881 68878 return enemy::animate(index);
12882 70891 }
12883
12884 70889 void eGohma::draw(BITMAP *dest)
12885 {
12886 70889 tile=o_tile;
12887
12888
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12889 {
12890 2012 enemy::drawzcboss(dest);
12891 2012 return;
12892 }
12893
12894
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12895 {
12896 ///if ( do_animation )
12897 //Yuck. Gohma can just not have this capability right now.
12898 // left side
12899 53472 xofs=-16;
12900 53472 flip=0;
12901 // if(clk&16) tile=180;
12902 // else { tile=182; flip=1; }
12903 53472 tile+=(3*((clk&48)>>4));
12904 53472 enemy::drawzcboss(dest);
12905
12906 // right side
12907 53472 xofs=16;
12908 // tile=(180+182)-tile;
12909 53472 tile=o_tile;
12910 53472 tile+=(3*((clk&48)>>4))+2;
12911 53472 enemy::drawzcboss(dest);
12912
12913 // body
12914 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12915 53472 tile=o_tile;
12916
12917 // tile+=(3*((clk&24)>>3))+2;
12918
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12919 2975 tile+=7;
12920
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12921 15890 tile+=10;
12922
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12923 2051 tile+=7;
12924 else
12925 32556 tile+=((clk3-132)&24)?4:1;
12926
12927 53472 enemy::drawzcboss(dest);
12928
12929 53472 }
12930 else
12931 {
12932 // left side
12933 15405 xofs=-16;
12934 15405 flip=0;
12935
12936
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12937 {
12938 7790 tile+=2;
12939 7790 flip=1;
12940 7790 }
12941
12942 15405 enemy::draw(dest);
12943
12944 // right side
12945 15405 tile=o_tile;
12946 15405 xofs=16;
12947
12948
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12949
12950 // tile=(180+182)-tile;
12951 15405 enemy::draw(dest);
12952
12953 // body
12954 15405 tile=o_tile;
12955 15405 xofs=0;
12956
12957
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12958 912 tile+=4;
12959
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12960 4882 tile+=5;
12961
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12962 585 tile+=4;
12963 9026 else tile+=((clk3-132)&8)?3:1;
12964
12965 15405 enemy::draw(dest);
12966
12967 }
12968 70889 }
12969
12970 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12971 {
12972 578 int32_t wpnId = w->id;
12973 578 int32_t power = w->power;
12974 578 int32_t wpnx = w->x;
12975 578 int32_t wpnDir = w->dir;
12976 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12977
12978
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12979 {
12980
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12981 {
12982 93 sfx(WAV_CHINK,pan(x));
12983 93 return 1;
12984 }
12985 328 }
12986
12987 485 return enemy::takehit(w, realweap);
12988 578 }
12989
12990 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12991 327 {
12992 327 count_enemy=(id==(id&0xFFF));
12993 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12994
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
12995 327 }
12996
12997 124050 bool eLilDig::animate(int32_t index)
12998 {
12999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13000
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13001 4410 return Dead(index);
13002
13003
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13004 {
13005 7105 removearmos(x,y);
13006 7105 }
13007
13008
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13009 {
13010
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13011 1161 step+=0.25;
13012 38646 }
13013
13014 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13015 119640 return enemy::animate(index);
13016 124050 }
13017
13018 124268 void eLilDig::draw(BITMAP *dest)
13019 {
13020 124268 tile = o_tile;
13021 // tile = 160;
13022 124268 int32_t fdiv = frate/4;
13023
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13024
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13025 124268 efrate:((clk>=(frate>>1))?1:0);
13026
13027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13028 {
13029
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13030 {
13031
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13032 {
13033 case up: //u
13034 11370 flip=0;
13035 11370 break;
13036
13037 case l_up: //d
13038 10699 flip=0;
13039 10699 tile+=4;
13040 10699 break;
13041
13042 case l_down: //l
13043 10722 flip=0;
13044 10722 tile+=8;
13045 10722 break;
13046
13047 case left: //r
13048 12015 flip=0;
13049 12015 tile+=12;
13050 12015 break;
13051
13052 case r_down: //ul
13053 10070 flip=0;
13054 10070 tile+=20;
13055 10070 break;
13056
13057 case down: //ur
13058 9554 flip=0;
13059 9554 tile+=24;
13060 9554 break;
13061
13062 case r_up: //dl
13063 8255 flip=0;
13064 8255 tile+=28;
13065 8255 break;
13066
13067 case right: //dr
13068 10033 flip=0;
13069 10033 tile+=32;
13070 10033 break;
13071 }
13072
13073 91457 tile+=f2;
13074 91457 }
13075 else
13076 {
13077 32811 tile+=(clk>=6)?1:0;
13078 }
13079 124268 }
13080
13081 124268 enemy::draw(dest);
13082 124268 }
13083
13084 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13085 80 {
13086
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13087 80 }
13088
13089 29662 bool eBigDig::animate(int32_t index)
13090 {
13091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13093 return Dead(index);
13094
13095
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13096 {
13097 4104 removearmos(x,y);
13098 4104 }
13099
13100
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13101 {
13102 case 0:
13103 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13104 29534 break;
13105
13106 case 1:
13107 64 ++misc;
13108 64 break;
13109
13110 case 2:
13111
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13112 {
13113 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13114 111 }
13115
13116
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13117 {
13118 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13119 30 }
13120
13121
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13122 {
13123 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13124 30 }
13125
13126
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13127 {
13128 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13129 30 }
13130
13131
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13132 {
13133 2 int guycarryingitem = guys.Count()-1;
13134 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13135 2 itemguy = false;
13136 2 }
13137
13138 64 stop_bgsfx(index);
13139
13140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13141
13142 64 return true;
13143 }
13144
13145 29598 return enemy::animate(index);
13146 29662 }
13147
13148 29658 void eBigDig::draw(BITMAP *dest)
13149 {
13150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13151 {
13152 update_enemy_frame();
13153 xofs-=8;
13154 yofs-=8;
13155 drawblock(dest,15);
13156 xofs+=8;
13157 yofs+=8;
13158 return;
13159 }
13160
13161 29658 tile = o_tile;
13162 29658 int32_t fdiv = frate/4;
13163
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13164
13165
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13166 29658 efrate:((clk>=(frate>>1))?1:0);
13167
13168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13169 {
13170
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13171 {
13172
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13173 {
13174 case up: //u
13175 1688 flip=0;
13176 1688 break;
13177
13178 case l_up: //d
13179 1684 flip=0;
13180 1684 tile+=8;
13181 1684 break;
13182
13183 case l_down: //l
13184 2031 flip=0;
13185 2031 tile+=40;
13186 2031 break;
13187
13188 case left: //r
13189 1910 flip=0;
13190 1910 tile+=48;
13191 1910 break;
13192
13193 case r_down: //ul
13194 2041 flip=0;
13195 2041 tile+=80;
13196 2041 break;
13197
13198 case down: //ur
13199 2043 flip=0;
13200 2043 tile+=88;
13201
13202 2043 break;
13203
13204 case r_up: //dl
13205 1514 flip=0;
13206 1514 tile+=120;
13207 1514 break;
13208
13209 case right: //dr
13210 2241 flip=0;
13211 2241 tile+=128;
13212 2241 break;
13213 }
13214
13215 16161 tile+=(f2*2);
13216 16161 }
13217 else
13218 {
13219 13497 tile+=(f2)?0:2;
13220 13497 flip=(clk&1)?1:0;
13221 }
13222 29658 }
13223
13224 29658 xofs-=8;
13225 29658 yofs-=8;
13226 29658 drawblock(dest,15);
13227 29658 xofs+=8;
13228 29658 yofs+=8;
13229 29658 }
13230
13231 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13232 {
13233 869 int32_t wpnId = w->id;
13234
13235
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13236 {
13237 64 misc = 1;
13238 64 w->hit_pierce(this, 0, false);
13239 64 }
13240
13241 869 return 0;
13242 }
13243
13244 80 void eBigDig::init_size_flags()
13245 {
13246 80 SIZEflags = d->SIZEflags;
13247
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13248 // al_trace("Enemy txsz:%i\n", txsz);
13249
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13251 80 else hit_width = 32;
13252
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13253 80 else hit_height = 32;
13254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13255 80 else hzsz = 16; // hard to jump.
13256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13257 80 else hxofs = -8;
13258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13259 80 else hyofs = -8;
13260 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13261
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13262
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13263 {
13264 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13265 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13266 }
13267
13268
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13269 80 }
13270
13271 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13272 13 {
13273 13 hxofs=hyofs=8;
13274
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13275 {
13276 hxofs = 4;
13277 hyofs = 4;
13278 hit_width = 24;
13279 hit_height = 24;
13280 SIZEflags|=OVERRIDE_HIT_WIDTH;
13281 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13282 }
13283 13 hzsz=16; //can't be jumped.
13284 13 clk2=70;
13285 13 misc=-1;
13286
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13287
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13288 13 }
13289
13290 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13291 {
13292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13293
13294 return Dead(index);
13295
13296
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13297 {
13298 72 removearmos(x,y);
13299 72 }
13300
13301
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13302 {
13303 case -1:
13304 13 misc=0;
13305 [[fallthrough]];
13306 case 0:
13307
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13308 {
13309 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13310 173 sfx(wpnsfx(wpn),pan(x));
13311 173 clk2=0;
13312 173 }
13313
13314 12693 Stunclk=0;
13315 12693 constant_walk(rate,homing,spw_none);
13316 12693 break;
13317
13318 case 1:
13319 case 2:
13320
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13321 {
13322 41 int32_t r=zc_oldrand();
13323
13324
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13325 {
13326 17 y=96;
13327
13328
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13329 6 x=160;
13330 else
13331 11 x=48;
13332
13333
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13334 8 x=208-x;
13335
13336 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13337 17 }
13338
13339 41 loadpalset(csBOSS,pSprite(d->bosspal));
13340 41 misc=0;
13341 41 }
13342
13343 3607 break;
13344
13345 case 3:
13346 {
13347
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13348 972 break;
13349
13350 12 misc=4;
13351 12 clk=0;
13352 12 hxofs=1000;
13353 12 loadpalset(9,pSprite(spPILE));
13354 12 music_stop();
13355 12 stop_sfx(WAV_ROAR);
13356
13357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13358
13359 12 sfx(WAV_GANON);
13360 //Ganon's dustpile; fall in sideview. -Z
13361 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13362 //dustpile->miscellaneous[31] = eeGANON;
13363
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13364 12 item *dustpile = NULL;
13365 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13366 12 dustpile = (item *)items.spr(items.Count() - 1);
13367 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13368 12 break;
13369 }
13370
13371 case 4:
13372
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13373 {
13374 12 misc=5;
13375
13376 //game->lvlitems[dlevel]|=(1 << li_boss_killed);
13377
13378 12 sfx(WAV_CLEARED);
13379 //Add the big TF over the ashes!
13380
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13381 {
13382 24 item *ashes = (item*)items.spr(q);
13383
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13384 {
13385 //Z_scripterrlog("Found correct dustpile!\n");
13386
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13387 12 item *bigtriforce = NULL;
13388 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13389 12 bigtriforce->linked_parent = eeGANON;
13390 12 }
13391 24 }
13392 12 }
13393
13394 960 break;
13395 10 case 5: return true;
13396 }
13397
13398 18244 return enemy::animate(index);
13399 18254 }
13400
13401
13402 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13403 {
13404 //these are here to bypass compiler warnings about unused arguments
13405 964 int32_t wpnId = w->id;
13406 964 int32_t power = w->power;
13407 964 int32_t enemyHitWeapon = w->parentitem;
13408
13409
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13410 {
13411 case 0:
13412
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13413 31 return 0;
13414
13415 53 hp-=power;
13416
13417
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13418 {
13419 41 misc=1;
13420 41 Stunclk=64;
13421 41 }
13422 else
13423 {
13424 12 loadpalset(csBOSS,pSprite(spBROWN));
13425 12 misc=2;
13426 12 Stunclk=284;
13427 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13428 }
13429
13430 53 sfx(WAV_EHIT,pan(x));
13431
13432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13433
13434 53 return 1;
13435
13436 case 2:
13437
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13438 154 return 0;
13439
13440 12 misc=3;
13441 12 hclk=81;
13442 12 loadpalset(9,pSprite(spBROWN));
13443 12 return 1;
13444 }
13445
13446 714 return 0;
13447 964 }
13448
13449 20776 void eGanon::draw(BITMAP *dest)
13450 {
13451
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13452 {
13453 case 0:
13454
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13455 3169 tile=(zc_oldrand()%5)*2+o_tile;
13456
13457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13458 {
13459
13460 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13461 {
13462 int odraw = drawstyle;
13463 drawstyle = 2;
13464 drawblock(dest,15);
13465 drawstyle = odraw;
13466 }
13467 else
13468 {
13469 drawblock(dest,15);
13470 }
13471 break;
13472
13473 }
13474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13475 {
13476 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13477 {
13478 int odraw = drawstyle;
13479 drawstyle = 2;
13480 drawblock(dest,15);
13481 drawstyle = odraw;
13482 }
13483 else
13484 {
13485 drawblock(dest,15);
13486 }
13487 break;
13488 }
13489
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13490 12680 break;
13491 [[fallthrough]];
13492 case 2:
13493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13494 break;
13495 [[fallthrough]];
13496 case -1:
13497 3518 tile=o_tile;
13498
13499 [[fallthrough]];
13500 case 1:
13501 case 3:
13502 7126 drawblock(dest,15);
13503 7126 break;
13504
13505 case 4:
13506 960 draw_guts(dest);
13507 960 draw_flash(dest);
13508 960 break;
13509 }
13510 20776 }
13511
13512 960 void eGanon::draw_guts(BITMAP *dest)
13513 {
13514
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13515 960 tile = clk<24 ? 74 : 75;
13516 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13517 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13518 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13519 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13520 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13521 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13522 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13523 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13524 960 }
13525
13526 960 void eGanon::draw_flash(BITMAP *dest)
13527 {
13528
13529 960 int32_t c = clk-(clk>>2);
13530 960 cs = (frame&3)+6;
13531 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13532 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13533 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13534 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13535 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13536 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13537 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13538 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13539 960 }
13540
13541 15 void getBigTri(mapscr* scr, int32_t id2)
13542 {
13543 /*
13544 *************************
13545 * BIG TRIFORCE SEQUENCE *
13546 *************************
13547 0 BIGTRI out, WHITE flash in
13548 4 WHITE flash out, PILE cset white
13549 8 WHITE in
13550 ...
13551 188 WHITE out
13552 191 PILE cset red
13553 200 top SHUTTER opens
13554 209 bottom SHUTTER opens
13555 */
13556 15 sfx(itemsbuf[id2].playsound);
13557 15 guys.clear();
13558
13559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13560 {
13561 game->lvlitems[dlevel]|=(1 << li_mcguffin);
13562 }
13563
13564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13565
13566 15 draw_screen();
13567
13568
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13569 {
13570
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13571 {
13572
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13573 {
13574 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13575 225 }
13576 15 }
13577
13578
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13579 {
13580
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13581 {
13582
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13583 {
13584 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13585 16200 }
13586 1080 }
13587
13588 360 refreshpal=true;
13589 360 }
13590
13591
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13592 {
13593
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13594 else loadlvlpal(0xB);
13595 360 }
13596
13597
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13598 {
13599 15 loadpalset(9,pSprite(spPILE));
13600 15 }
13601
13602 2880 advanceframe(true);
13603 2880 }
13604
13605 //play_DmapMusic();
13606 15 playLevelMusic();
13607
13608
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13609 {
13610 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13611 2 }
13612 15 }
13613
13614 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13615 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13616 618 {
13617
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13618 {
13619
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13620 618 }
13621 //else { x = X; y = Y; }
13622
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13623 618 superman=1;
13624 618 fading=fade_invisible;
13625 618 hxofs=1000;
13626 618 segcnt=clk;
13627 618 segid=Id|0x1000;
13628 618 clk=0;
13629
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13630
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13631 618 tile=o_tile;
13632 618 hitdir = -1;
13633 618 stickclk = 0;
13634
13635 /*
13636 if (get_qr(qr_NEWENEMYTILES))
13637 {
13638 tile=nets+1220;
13639 }
13640 else
13641 {
13642 tile=57;
13643 }
13644 */
13645 618 }
13646
13647 244844 bool eMoldorm::animate(int32_t index)
13648 {
13649 244844 update_current_screen();
13650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13651 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13652
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13653 {
13654 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13655 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13656 28475 }
13657
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13658 {
13659 562 stickclk = 0;
13660 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13661 562 }
13662
13663
13664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13665 {
13666 244844 removearmos(x,y);
13667 244844 }
13668
13669
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13670 {
13671
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13672 {
13673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13674 129 never_return(screen_spawned, index);
13675
13676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13677 129 leave_item();
13678
13679 129 stop_bgsfx(index);
13680 129 return true;
13681 }
13682 2322 }
13683 else
13684 {
13685
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13686 stunclk=0;
13687 242393 constant_walk_8_old(rate,homing,spw_floater);
13688
13689
13690 242393 misc=dir;
13691
13692 // If any higher-numbered segments were killed, segcnt can be too high,
13693 // leading to a crash
13694
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13695 segcnt=guys.Count()-index-1;
13696
13697
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13698 {
13699 1122281 enemy* segment=((enemy*)guys.spr(i));
13700
13701 // More validation - if segcnt was wrong, this may not
13702 // actually be a Moldorm segment
13703
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13704 {
13705 segcnt=i-index-1;
13706 break;
13707 }
13708
13709
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13710 {
13711 242669 x=segment->x;
13712 242669 y=segment->y;
13713 242669 }
13714
13715 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13716 //Script your own blasted segmented bosses!! -Z
13717 1122281 segment->setParent(this);
13718
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13719 {
13720 217733 segment->dummy_int[1]=2;
13721 217733 }
13722 else
13723 {
13724 904548 segment->dummy_int[1]=1;
13725 }
13726
13727
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13728 {
13729 242669 segment->dummy_int[1]=0;
13730 242669 }
13731
13732
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13733 {
13734 1016 int32_t offset=1;
13735
13736
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13737 {
13738 // Triple-check
13739
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13740 {
13741 segcnt=j-index+1; // Add 1 because of --segcnt below
13742 break;
13743 }
13744 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13745 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13746 1480 }
13747
13748 1016 segment->hclk=33;
13749 1016 --segcnt;
13750 1016 --i; // Recheck the same index in case multiple segments died at once
13751 1016 }
13752 1122281 }
13753
13754
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13755 {
13756 129 clk2=19;
13757
13758 129 x=guys.spr(index+1)->x;
13759 129 y=guys.spr(index+1)->y;
13760 129 }
13761 }
13762
13763 244715 return false;
13764 244844 }
13765
13766 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13767 3150 {
13768
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13769 {
13770
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13771 3150 }
13772
13773
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13774 3150 hyofs=4;
13775 3150 hit_width=hit_height=8;
13776 3150 hxofs=1000;
13777 3150 mainguy=count_enemy=false;
13778 3150 parentclk = 0;
13779 3150 bgsfx=-1;
13780
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13781 //deadsfx = WAV_EDEAD;
13782 3150 isCore = false;
13783 3150 }
13784
13785 1138024 bool esMoldorm::animate(int32_t index)
13786 {
13787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13788 // Shouldn't be possible, but better to be sure
13789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13790 dying=true;
13791
13792
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13793 {
13794
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13795 15743 item_set=0;
13796
13797 15743 return Dead(index);
13798 }
13799
13800
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13801 {
13802 1017204 hxofs=4;
13803 1017204 step=((enemy*)guys.spr(index-1))->step;
13804
13805
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13806 {
13807 70455 misc=dir;
13808 70455 dir=((enemy*)guys.spr(index-1))->misc;
13809 //do alignment, as in parent's animation :-/ -DD
13810 70455 x.doFloor();
13811 70455 y.doFloor();
13812 70455 }
13813
13814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13815 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13816
13817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13818 {
13819 1017204 sprite::move(step);
13820 1017204 }
13821 1017204 }
13822
13823 1122281 return enemy::animate(index);
13824 1138024 }
13825
13826 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13827 {
13828
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13829 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13830
13831 453 return 0;
13832 2683 }
13833
13834 1155313 void esMoldorm::draw(BITMAP *dest)
13835 {
13836 1155313 tile=o_tile;
13837 1155313 int32_t fdiv = frate/4;
13838
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13839
13840
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13841 1155313 efrate:((clk>=(frate>>1))?1:0);
13842
13843
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13844 {
13845 1043930 tile+=dummy_int[1]*40;
13846
13847
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13848 {
13849 102730 flip=0;
13850
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13851
13852
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13853 tile+=4;
13854 102730 }
13855 else
13856 {
13857
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13858 {
13859 case up: //u
13860 96530 flip=0;
13861 96530 break;
13862
13863 case l_up: //d
13864 134534 flip=0;
13865 134534 tile+=4;
13866 134534 break;
13867
13868 case l_down: //l
13869 113426 flip=0;
13870 113426 tile+=8;
13871 113426 break;
13872
13873 case left: //r
13874 124800 flip=0;
13875 124800 tile+=12;
13876 124800 break;
13877
13878 case r_down: //ul
13879 101314 flip=0;
13880 101314 tile+=20;
13881 101314 break;
13882
13883 case down: //ur
13884 99043 flip=0;
13885 99043 tile+=24;
13886 99043 break;
13887
13888 case r_up: //dl
13889 131794 flip=0;
13890 131794 tile+=28;
13891 131794 break;
13892
13893 case right: //dr
13894 139759 flip=0;
13895 139759 tile+=32;
13896 139759 break;
13897 }
13898 }
13899
13900 1043930 tile+=f2;
13901 1043930 }
13902
13903
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13904 1049046 enemy::draw(dest);
13905 1155313 }
13906
13907 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13908 420 {
13909
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13910 {
13911
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13912 420 }
13913 //else { x = X; y = Y; }
13914 //byte legaldirs = 0;
13915 420 int32_t incr = 16;
13916 //int32_t possiiblepos = 0;
13917 //int32_t positions[8] = {0};
13918
13919 //Don't spawn in pits.
13920
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13921 {
13922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13923 {
13924 //move if we spawn over a pit
13925 //check each direction
13926
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13927 {
13928
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13929 }
13930
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13931 {
13932
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13933 }
13934
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13935 {
13936
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13937 }
13938
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13939 {
13940
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13941 }
13942
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13943 {
13944 y -= incr; break;
13945 }
13946
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13947 {
13948 y+=incr; break;
13949 }
13950
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13951 {
13952
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13953 }
13954
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13955 {
13956 x+=incr; y+=incr; break;
13957 }
13958 34 else continue;
13959
13960 }
13961
13962 105 }
13963
13964 420 dir=up;
13965 420 superman=1;
13966 420 fading=fade_invisible;
13967 420 hxofs=1000;
13968 420 segcnt=clk;
13969 420 clk=0;
13970 //set up move history
13971
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13972
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13973 420 }
13974
13975 236907 bool eLanmola::animate(int32_t index)
13976 {
13977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13978
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13979 {
13980 40196 removearmos(x,y);
13981 40196 }
13982
13983
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13984 {
13985
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
13986 {
13987
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
13988 86 leave_item();
13989
13990 189 stop_bgsfx(index);
13991 189 return true;
13992 }
13993
13994 3402 return false;
13995 }
13996
13997
13998 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
13999 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14000 //I've added a complete movement history to this enemy to compensate -DD
14001 233316 constant_walk(rate,homing,spw_none);
14002 233316 prevState.pop_front();
14003 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14004
14005 // This could cause a crash with Moldorms. I didn't see the same problem
14006 // with Lanmolas, but it looks like it ought to be possible, so here's
14007 // the same solution. - Saf
14008
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14009 segcnt=guys.Count()-index-1;
14010
14011
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14012 {
14013 966396 enemy* segment=((enemy*)guys.spr(i));
14014
14015 // More validation in case segcnt is wrong
14016
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14017 {
14018 segcnt=i-index-1;
14019 break;
14020 }
14021
14022 966396 segment->o_tile=o_tile;
14023 966396 segment->setParent(this);
14024
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14025 {
14026 195700 segment->dummy_int[1]=1; //tail
14027 195700 }
14028 else
14029 {
14030 770696 segment->dummy_int[1]=0;
14031 }
14032
14033
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14034 {
14035
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14036 {
14037 // Triple-check
14038
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14039 {
14040 segcnt=j-index+1; // Add 1 because of --segcnt below
14041 break;
14042 }
14043 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14044 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14045 1961 }
14046
14047 1169 ((enemy*)guys.spr(i))->hclk=33;
14048 1169 --segcnt;
14049 1169 --i; // Recheck the same index in case multiple segments died at once
14050 1169 }
14051 966396 }
14052
14053
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14054 {
14055 189 clk2=19;
14056 189 x=guys.spr(index+1)->x;
14057 189 y=guys.spr(index+1)->y;
14058 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14059 189 }
14060
14061 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14062 //which is... disastrous.
14063 233316 hp = 1;
14064 233316 return enemy::animate(index);
14065 236907 }
14066
14067 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14068 2267 {
14069
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14070 {
14071
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14072 2267 }
14073 2267 int32_t incr = 16;
14074 //Don't spawn in pits.
14075
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14076 {
14077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14078 {
14079 //move if we spawn over a pit
14080 //check each direction
14081
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14082 {
14083
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14084 }
14085
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14086 {
14087
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14088 }
14089
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14090 {
14091
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14092 }
14093
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14094 {
14095
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14096 }
14097
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14098 {
14099 y -= incr; break;
14100 }
14101
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14102 {
14103 y+=incr; break;
14104 }
14105
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14106 {
14107
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14108 }
14109
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14110 {
14111 x+=incr; y+=incr; break;
14112 }
14113 170 else continue;
14114
14115 }
14116
14117 525 }
14118
14119 2267 hxofs=1000;
14120 2267 hit_width=8;
14121 2267 mainguy=false;
14122 2267 count_enemy=(id<0x2000)?true:false;
14123
14124 //set up move history
14125
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14126
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14127
14128 2267 bgsfx = -1;
14129 2267 isCore = false;
14130
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14131 2267 }
14132
14133 985563 bool esLanmola::animate(int32_t index)
14134 {
14135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14136 // Shouldn't be possible, but who knows
14137
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14138 18 dying=true;
14139
14140
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14141 {
14142 19167 xofs=0;
14143
14144
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14145 9306 item_set=0;
14146
14147 19167 return Dead(index);
14148 }
14149
14150
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14151 {
14152 930450 hxofs=4;
14153
14154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14155 {
14156 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14157 930450 prevState.pop_front();
14158 930450 prevState.push_back(newstate);
14159 930450 x = newstate.first.first;
14160 930450 y = newstate.first.second;
14161 930450 dir = newstate.second;
14162 930450 }
14163 930450 }
14164
14165 966396 return enemy::animate(index);
14166 985563 }
14167
14168 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14169 {
14170
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14171 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14172
14173 590 return 0;
14174 2655 }
14175
14176 990931 void esLanmola::draw(BITMAP *dest)
14177 {
14178 990931 tile=o_tile;
14179 990931 int32_t fdiv = frate/4;
14180
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14181
14182
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14183 990931 efrate:((clk>=(frate>>1))?1:0);
14184
14185
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14186 {
14187
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14188 {
14189 481767 tile+=20;
14190
14191
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14192 {
14193 128742 tile+=20;
14194 128742 }
14195 481767 }
14196
14197
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14198 {
14199 case up:
14200 141419 flip=0;
14201 141419 break;
14202
14203 case down:
14204 140994 flip=0;
14205 140994 tile+=4;
14206 140994 break;
14207
14208 case left:
14209 159500 flip=0;
14210 159500 tile+=8;
14211 159500 break;
14212
14213 case right:
14214 187019 flip=0;
14215 187019 tile+=12;
14216 187019 break;
14217 }
14218
14219 628932 tile+=f2;
14220 628932 }
14221 else
14222 {
14223
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14224 {
14225 271456 tile+=1;
14226 271456 }
14227 }
14228
14229
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14230 953893 enemy::draw(dest);
14231 990931 }
14232
14233 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14234 150 {
14235 //these are here to bypass compiler warnings about unused arguments
14236 150 Clk=Clk;
14237 150 superman=1;
14238
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14239 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14240
14241
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14242 692 arm[i]=i;
14243
14244 150 fading=fade_blue_poof;
14245 //nets+4680;
14246 150 adjusted=false;
14247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14248 150 }
14249
14250 66494 bool eManhandla::animate(int32_t index)
14251 {
14252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14253
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14254 1382 return Dead(index);
14255
14256
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14257 {
14258 2471 removearmos(x,y);
14259 2471 }
14260
14261
14262 // check arm status, move dead ones to end of group
14263
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14264 {
14265 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14266
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14267 {
14268
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14269 {
14270 552 zc_swap(arm[j],arm[j+1]);
14271 552 guys.swap(index+j+1,index+j+2);
14272 552 }
14273
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14274 {
14275 87 leave_item();
14276 87 }
14277 424 --armcnt;
14278 424 --i;
14279 424 continue;
14280 }
14281
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14282 {
14283
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14284 {
14285 508 cur_arm->o_tile=o_tile+40;
14286 508 cur_arm->setParent(this);
14287 508 }
14288 else
14289 {
14290 184 cur_arm->o_tile=o_tile+160;
14291 184 cur_arm->setParent(this);
14292 }
14293 692 }
14294 193194 }
14295
14296 65112 adjusted=true;
14297
14298 // move or die
14299
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14300 83 hp=0;
14301 else
14302 {
14303 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14304
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14305
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14306 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14307
14308
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14309 {
14310
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14311 {
14312
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14313 {
14314 case 0:
14315 38579 dy1=-24;
14316 38579 break;
14317
14318 case 1:
14319 36328 dy2=31;
14320 36328 break;
14321
14322 case 2:
14323 36250 dx1=-16;
14324 36250 break;
14325
14326 case 3:
14327 39862 dx2=31;
14328 39862 break;
14329 }
14330 151019 }
14331 53584 }
14332 else
14333 {
14334 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14335
14336
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14337 {
14338
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14339 {
14340 case 0:
14341 12012 dy1=-32;
14342 12012 break;
14343
14344 case 1:
14345 7730 dy2=39;
14346 7730 break;
14347
14348 case 2:
14349 9837 dx1=-24;
14350 9837 break;
14351
14352 case 3:
14353 12596 dx2=39;
14354 12596 break;
14355 }
14356 42175 }
14357 }
14358
14359 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14360
14361
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14362 {
14363 193194 zfix dx=(zfix)0,dy=(zfix)0;
14364
14365
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14366 {
14367
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14368 {
14369 case 0:
14370 38579 dy=-16;
14371 38579 break;
14372
14373 case 1:
14374 36328 dy=16;
14375 36328 break;
14376
14377 case 2:
14378 36250 dx=-16;
14379 36250 break;
14380
14381 case 3:
14382 39862 dx=16;
14383 39862 break;
14384 }
14385 151019 }
14386 else
14387 {
14388
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14389 {
14390 case 0:
14391 5447 dy=-24;
14392 5447 dx=-8;
14393 5447 break;
14394
14395 case 1:
14396 3986 dy=24;
14397 3986 dx=8;
14398 3986 break;
14399
14400 case 2:
14401 4163 dx=-24;
14402 4163 dy=8;
14403 4163 break;
14404
14405 case 3:
14406 6774 dx=24;
14407 6774 dy=-8;
14408 6774 break;
14409
14410 case 4:
14411 6565 dy=-24;
14412 6565 dx=8;
14413 6565 break;
14414
14415 case 5:
14416 3744 dy=24;
14417 3744 dx=-8;
14418 3744 break;
14419
14420 case 6:
14421 5674 dx=-24;
14422 5674 dy=-8;
14423 5674 break;
14424
14425 case 7:
14426 5822 dx=24;
14427 5822 dy=8;
14428 5822 break;
14429 }
14430 }
14431
14432 193194 guys.spr(index+i+1)->x = x+dx;
14433 193194 guys.spr(index+i+1)->y = y+dy;
14434 193194 }
14435 }
14436
14437 65112 return enemy::animate(index);
14438 66494 }
14439
14440
14441 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14442 {
14443 1751 int32_t wpnId = w->id;
14444
14445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14446 return 0;
14447
14448
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14449 {
14450 case wBomb:
14451 case wSBomb:
14452 case wSword:
14453 case wHammer:
14454 case wWand:
14455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14456
14457 case wLitBomb:
14458 case wLitSBomb:
14459 case wBait:
14460 case wWhistle:
14461 case wFire:
14462 case wWind:
14463 case wSSparkle:
14464 case wFSparkle:
14465 case wPhantom:
14466 1709 return 0;
14467
14468 case wHookshot:
14469 case wBrang:
14470 sfx(WAV_CHINK,pan(x));
14471 break;
14472
14473 default:
14474
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14475 else sfx(WAV_CHINK,pan(x));
14476
14477 42 }
14478
14479 42 return 1;
14480 1751 }
14481
14482 66490 void eManhandla::draw(BITMAP *dest)
14483 {
14484 66490 tile=o_tile;
14485 66490 int32_t fdiv = frate/4;
14486
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14487
14488
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14489 66490 efrate:((clk>=(frate>>1))?1:0);
14490
14491
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14492 {
14493
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14494 {
14495
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14496 {
14497 case up: //u
14498 4771 flip=0;
14499 4771 break;
14500
14501 case l_up: //d
14502 4640 flip=0;
14503 4640 tile+=4;
14504 4640 break;
14505
14506 case l_down: //l
14507 4995 flip=0;
14508 4995 tile+=8;
14509 4995 break;
14510
14511 case left: //r
14512 5574 flip=0;
14513 5574 tile+=12;
14514 5574 break;
14515
14516 case r_down: //ul
14517 3793 flip=0;
14518 3793 tile+=20;
14519 3793 break;
14520
14521 case down: //ur
14522 3930 flip=0;
14523 3930 tile+=24;
14524 3930 break;
14525
14526 case r_up: //dl
14527 3908 flip=0;
14528 3908 tile+=28;
14529 3908 break;
14530
14531 case right: //dr
14532 5883 flip=0;
14533 5883 tile+=32;
14534 5883 break;
14535 }
14536
14537 37494 tile+=f2;
14538 37494 enemy::draw(dest);
14539 37494 } //manhandla 2, big body
14540 else
14541 {
14542
14543
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14544 {
14545 case up: //u
14546 1277 flip=0;
14547 1277 break;
14548
14549 case l_up: //d
14550 1360 flip=0;
14551 1360 tile+=8;
14552 1360 break;
14553
14554 case l_down: //l
14555 2242 flip=0;
14556 2242 tile+=40;
14557 2242 break;
14558
14559 case left: //r
14560 1789 flip=0;
14561 1789 tile+=48;
14562 1789 break;
14563
14564 case r_down: //ul
14565 1345 flip=0;
14566 1345 tile+=80;
14567 1345 break;
14568
14569 case down: //ur
14570 805 flip=0;
14571 805 tile+=88;
14572 805 break;
14573
14574 case r_up: //dl
14575 948 flip=0;
14576 948 tile+=120;
14577 948 break;
14578
14579 case right: //dr
14580 1542 flip=0;
14581 1542 tile+=128;
14582 1542 break;
14583 }
14584
14585 11308 tile+=(f2*2);
14586 11308 xofs-=8;
14587 11308 yofs-=8;
14588 11308 drawblock(dest,15);
14589 11308 xofs+=8;
14590 11308 yofs+=8;
14591 }
14592 48802 }
14593 else
14594 {
14595
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14596 {
14597 17173 enemy::draw(dest);
14598 17173 }
14599 else
14600 {
14601 515 xofs-=8;
14602 515 yofs-=8;
14603 515 enemy::draw(dest);
14604 515 xofs+=16;
14605 515 enemy::draw(dest);
14606 515 yofs+=16;
14607 515 enemy::draw(dest);
14608 515 xofs-=16;
14609 515 enemy::draw(dest);
14610 515 xofs+=8;
14611 515 yofs-=8;
14612 }
14613 }
14614 66490 }
14615
14616 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14617 692 {
14618 692 id=misc=clk;
14619 692 dir = clk & 3;
14620 692 clk=0;
14621 692 mainguy=count_enemy=false;
14622 692 dummy_bool[0]=false;
14623 692 item_set=0;
14624 692 bgsfx=-1;
14625 692 deadsfx = WAV_EDEAD;
14626
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14627 692 isCore = false;
14628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14629 692 }
14630
14631 200202 bool esManhandla::animate(int32_t index)
14632 {
14633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14634
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14635 7008 return Dead(index);
14636
14637
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14638 {
14639 12404 removearmos(x,y);
14640 12404 }
14641
14642
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14643 {
14644 27896 clk2=unsigned(zc_oldrand())%5+5;
14645 27896 clk3^=1;
14646 27896 }
14647
14648
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14649 {
14650 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14651 1491 sfx(wpnsfx(wpn),pan(x));
14652 1491 }
14653
14654 193194 return enemy::animate(index);
14655 200202 }
14656
14657 200186 void esManhandla::draw(BITMAP *dest)
14658 {
14659 200186 tile=o_tile;
14660 200186 int32_t fdiv = frate/4;
14661
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14662
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14663 200186 efrate:((clk>=(frate>>1))?1:0);
14664
14665
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14666 {
14667
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14668 {
14669 case up:
14670 39945 break;
14671
14672 case down:
14673 36845 tile+=4;
14674 36845 break;
14675
14676 case left:
14677 39966 tile+=8;
14678 39966 break;
14679
14680 case right:
14681 41960 tile+=12;
14682 41960 break;
14683 }
14684
14685 158716 tile+=f2;
14686 158716 }
14687 else
14688 {
14689
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14690 {
14691 case down:
14692 8961 flip=2;
14693
14694 [[fallthrough]];
14695 case up:
14696 21355 tile=(clk3)?188:189;
14697 21355 break;
14698
14699 case right:
14700 12232 flip=1;
14701 [[fallthrough]];
14702
14703 case left:
14704 20115 tile=(clk3)?186:187;
14705 20115 break;
14706 }
14707 }
14708
14709 200186 enemy::draw(dest);
14710 200186 }
14711
14712 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14713 168 {
14714
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14715 {
14716
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14717 168 }
14718 else
14719 {
14720 if ( !(editorflags & ENEMY_FLAG6) )
14721 {
14722 x = X; y = Y;
14723 }
14724 else
14725 {
14726 x = X+8; y = Y;
14727 }
14728 }
14729 168 hzsz = 32; // can't be jumped.
14730 168 flameclk=0;
14731 168 misc=clk; // total head count
14732 168 clk3=clk; // live head count
14733 168 clk=0;
14734 168 clk2=60; // fire ball clock
14735 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14736
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14737 168 dir = down;
14738 168 hxofs=4;
14739 168 hit_width=8;
14740 // frate=17*4;
14741 168 fading=fade_blue_poof;
14742 //nets+5420;
14743
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14744 {
14745 /*
14746 necktile=o_tile+8;
14747 if (dmisc3)
14748 {
14749 necktile+=8;
14750 }
14751 */
14752 133 necktile=o_tile+dmisc6;
14753 133 }
14754 else
14755 {
14756 35 necktile=s_tile;
14757 }
14758 168 }
14759
14760 155290 bool eGleeok::animate(int32_t index)
14761 {
14762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14763
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14764 2199 return Dead(index);
14765
14766
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14767 {
14768 684 removearmos(x,y);
14769 684 }
14770
14771 // Check if a head was killed somehow...
14772
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14773 51372 clk3=guys.Count()-index-1;
14774
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14775 87041 misc=guys.Count()-index-1;
14776
14777 //fix for the "kill all enemies" item
14778
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14779 {
14780
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14781 {
14782 // I haven't seen this fail, but it seems like it ought to be
14783 // possible, so I'm checking for it. - Saf
14784
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14785 break;
14786 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14787 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14788 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14789 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14790 12 }
14791
14792 6 clk3=0;
14793
14794
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14795 {
14796
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14797 break;
14798 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14799 12 }
14800 6 }
14801
14802
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14803 {
14804 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14805 403171 head->dummy_int[1]=necktile;
14806 403171 head->setParent(this);
14807
14808
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14809 {
14810 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14811 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14812 320127 }
14813 else
14814 {
14815 83044 head->dummy_int[2]=necktile+1; //connected head tile
14816 83044 head->dummy_int[3]=necktile+2; //flying head tile
14817 }
14818
14819 403171 head->dmisc5=dmisc5; //neck segments
14820
14821 /*
14822 if (dmisc3)
14823 {
14824 head->dummy_bool[0]=true;
14825 }
14826 */
14827
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14828 {
14829
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14830 {
14831 1228 hp -= 1000 - head->hp;
14832 1228 hclk = 33;
14833
14834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14835
14836 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14837 1228 }
14838
14839 5655 head->hclk = 0;
14840 5655 }
14841
14842 // Must be set in case of naughty ZScripts
14843 403171 head->hp = 1000;
14844 403171 }
14845
14846
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14847 {
14848 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14849 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14850 415 }
14851
14852
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14853 {
14854
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14855 {
14856 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14857 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14858 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14859 1287 sfx(wpnsfx(wpn),pan(x));
14860 1287 clk2=0;
14861 1287 }
14862 95682 }
14863 else
14864 {
14865
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14866 {
14867 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14868 557 head->timer=zc_oldrand()%50+50;
14869 557 clk2=0;
14870 557 }
14871 }
14872
14873
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14874 {
14875
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14876 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14877
14878
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14879 127 }
14880
14881 153091 return enemy::animate(index);
14882 155290 }
14883
14884 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14885 {
14886 1239 return 0;
14887 }
14888
14889 156918 void eGleeok::draw(BITMAP *dest)
14890 {
14891 156918 tile=o_tile;
14892
14893
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14894 {
14895 2199 enemy::draw(dest);
14896 2199 return;
14897 }
14898
14899 154719 int32_t f=clk/17;
14900
14901
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14902 {
14903 // body
14904 120524 xofs=-8;
14905 120524 yofs=32;
14906
14907
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14908
14909 {
14910 case 0:
14911 9155 tile+=0;
14912 9155 break;
14913
14914 case 1:
14915 10095 tile+=2;
14916 10095 break;
14917
14918 case 2:
14919 8686 tile+=4;
14920 8686 break;
14921
14922 default:
14923 92588 tile+=6;
14924 92588 break;
14925 }
14926 120524 }
14927 else
14928 {
14929 // body
14930 34195 xofs=-8;
14931 34195 yofs=32;
14932
14933
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14934 {
14935 case 0:
14936 2514 tile+=0;
14937 2514 break;
14938
14939 case 2:
14940 2459 tile+=4;
14941 2459 break;
14942
14943 default:
14944 29222 tile+=2;
14945 29222 break;
14946 }
14947 }
14948
14949 154719 enemy::drawblock(dest,15);
14950 156918 }
14951
14952 156918 void eGleeok::draw2(BITMAP *dest)
14953 {
14954 // the neck stub
14955 156918 tile=necktile;
14956 156918 xofs=0;
14957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14958
14959
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14960 {
14961 122181 tile+=((clk&24)>>3);
14962 122181 }
14963
14964
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14965 {
14966 154719 mapscr* scr = get_scr(screen_spawned);
14967
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14968 737 sprite::drawcloaked(dest);
14969 else
14970 153982 sprite::draw(dest);
14971 154719 }
14972 156918 }
14973
14974
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14975 533 {
14976
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14977
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14978
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14979 // dummy_bool[0]=false;
14980 533 timer=0;
14981 /* fixing */
14982 533 hp=1000;
14983
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14984 533 item_set=0;
14985
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
14986
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
14987 533 hxofs=4;
14988 533 hit_width=8;
14989
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14990 533 clk2=clk; // how int32_t to wait before moving first time
14991 533 clk=0;
14992 533 mainguy=count_enemy=false;
14993
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
14994 533 clk3=((dir&2)>>1)+2; // left or right
14995 533 dir&=1; // up or down
14996
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
14997 533 isCore = false;
14998
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
14999
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15000 {
15001 2132 nxoffset[i] = 0;
15002 2132 nyoffset[i] = 0;
15003
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15004
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15005 2132 }
15006
15007 533 necktile=0;
15008 //TODO compatibility? -DD
15009 /*
15010 for(int32_t i=0; i<4; i++)
15011 {
15012 nx[i]=124;
15013 ny[i]=i*6+48;
15014 }*/
15015 533 bgsfx=-1;
15016 //no need for deadsfx
15017 533 }
15018
15019 515535 bool esGleeok::animate(int32_t index)
15020 {
15021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15022 // don't call removearmos() - it's a segment.
15023
15024 515535 dmisc5=vbound(dmisc5,1,255);
15025
15026
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15027 {
15028 402762 x = (xoffset+parent->x);
15029 402762 y = (yoffset+parent->y);
15030
15031
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15032 {
15033 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15034 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15035 1611048 }
15036 402762 }
15037
15038 // set up the head tiles
15039 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15040 /*
15041 if (dummy_bool[0]) //if this is a flame gleeok
15042 {
15043 headtile+=180;
15044 }
15045 */
15046 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15047 515535 flyingheadtile=dummy_int[3];
15048
15049 // set up the neck tiles
15050 515535 necktile=dummy_int[1];
15051
15052
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15053 {
15054 402833 necktile+=((clk&24)>>3);
15055 402833 }
15056
15057 /*
15058 else
15059 {
15060 necktile=145;
15061 }
15062 */
15063 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15064
15065
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15066 {
15067 case 0: // live head
15068 // set up the attached head tiles
15069 402762 tile=headtile;
15070
15071
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15072 {
15073 319820 tile+=((clk&24)>>3);
15074 /*
15075 if (dummy_bool[0]) {
15076 tile+=1561;
15077 }
15078 */
15079 319820 }
15080
15081 /*
15082 else
15083 {
15084 tile=146;
15085 }
15086 */
15087
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15088 {
15089
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15090
15091
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15092
15093
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15094 {
15095 292 dir^=1;
15096 292 }
15097
15098 92832 zfix tempx = x;
15099 92832 zfix tempy = y;
15100
15101 92832 sprite::move(step);
15102 92832 xoffset += (x-tempx);
15103 92832 yoffset += (y-tempy);
15104
15105
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15106 {
15107 3863 clk3^=1;
15108 3863 clk2=-4;
15109 3863 }
15110 else
15111 {
15112
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15113 {
15114 978 clk3=right;
15115 978 }
15116
15117
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15118 {
15119 961 clk3=left;
15120 961 }
15121
15122
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15123 {
15124 3713 clk3^=1; // x jig
15125 3713 }
15126 else
15127 {
15128
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15129 {
15130 851 clk3^=1; // x switch back
15131 851 }
15132
15133 85256 clk2=-4;
15134 }
15135 }
15136
15137 92832 zc_swap(dir,clk3);
15138 92832 tempx = x;
15139 92832 tempy = y;
15140 92832 sprite::move(step);
15141 92832 xoffset += (x-tempx);
15142 92832 yoffset += (y-tempy);
15143 92832 zc_swap(dir,clk3);
15144
15145
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15146 {
15147 278496 nxoffset[i] = (zc_oldrand()%3);
15148 278496 nyoffset[i] = (zc_oldrand()%3);
15149 278496 }
15150 92832 }
15151
15152 402762 break;
15153
15154 case 1: // flying head
15155
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15156
15157 {
15158 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15159 105482 }
15160
15161 112071 break;
15162
15163 // the following are messages sent from the main guy...
15164 case -1: // got chopped off
15165 {
15166 300 misc=1;
15167 300 superman=1;
15168 300 hxofs=xofs=0;
15169 300 hit_width=16;
15170 300 cs=8;
15171 300 clk=-24;
15172 300 clk2=40;
15173 300 dir=(zc_oldrand()&7)+8;
15174 300 step=8.0/9.0;
15175 }
15176 300 break;
15177
15178 case -2: // the big guy is dead
15179 402 return true;
15180 }
15181
15182
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15183 {
15184
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15185 {
15186 4791 FireBreath(true);
15187 4791 }
15188
15189 40125 --timer;
15190 40125 }
15191
15192 515133 return enemy::animate(index);
15193 515535 }
15194
15195 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15196 {
15197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15198 {
15199 int32_t wpnId = w->id;
15200
15201 if(dying)
15202 return 0;
15203
15204 switch(wpnId)
15205 {
15206 case wLitBomb:
15207 case wLitSBomb:
15208 case wBait:
15209 case wWhistle:
15210 case wFire:
15211 case wWind:
15212 case wSSparkle:
15213 case wFSparkle:
15214 case wPhantom:
15215 return 0;
15216
15217 case wHookshot:
15218 case wBrang:
15219 case wBeam:
15220 case wArrow:
15221 case wMagic:
15222 case wBomb:
15223 case wSBomb:
15224 sfx(WAV_CHINK,pan(x));
15225 break;
15226 default:
15227 break;
15228 }
15229
15230 return 1;
15231 }
15232 else
15233 {
15234 7080 int32_t ret = enemy::takehit(w,realweap);
15235
15236
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15237 5655 return -2; // force it to wait a frame before checking sword attacks again
15238
15239 1425 return ret;
15240 }
15241 7080 }
15242
15243 521456 void esGleeok::draw(BITMAP *dest)
15244 {
15245 521456 dmisc5=vbound(dmisc5,1,255);
15246
15247
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15248 {
15249 case 0: //neck
15250
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15251 {
15252
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15253 {
15254 1227318 mapscr* scr = get_scr(screen_spawned);
15255
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15256 {
15257
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15258 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15259 else
15260 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15261 978198 }
15262 else
15263 {
15264
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15265 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15266 else
15267 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15268 }
15269 1227318 }
15270 409106 }
15271
15272 409106 break;
15273
15274 case 1: //flying head
15275 112350 tile=flyingheadtile;
15276
15277
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15278 {
15279 82692 tile+=((clk&24)>>3);
15280 82692 break;
15281 }
15282 29658 }
15283 521456 }
15284
15285 521456 void esGleeok::draw2(BITMAP *dest)
15286 {
15287 521456 enemy::draw(dest);
15288 521456 }
15289
15290 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15291 190 {
15292
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15293 {
15294
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15295
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15296 190 }
15297 else { x = X; y = Y; }
15298 190 adjusted=false;
15299
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15300 //step=0.25;
15301 190 flycnt=dmisc1;
15302 190 flycnt2=dmisc2;
15303 190 loopcnt=0;
15304 190 clk4 = 0;
15305 190 clk5 = 0;
15306 190 clk6 = 0;
15307 190 clk7 = 0;
15308
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15310 {
15311
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15312 {
15313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15314 105 else dmisc29 = (84 / 3);
15315 105 }
15316 else
15317 {
15318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15319 85 else dmisc29 = (84 / 2);
15320 }
15321 190 }
15322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15323 {
15324
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15327 105 else dmisc30 = (84 / 3)*0.5;
15328 105 }
15329 else
15330 {
15331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15332 85 else dmisc30 = (84 / 2)*0.5;
15333 }
15334 190 }
15335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15336 {
15337
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15338 {
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15340 105 else dmisc31 = (84 / 3)*2;
15341 105 }
15342 else
15343 {
15344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15345 85 else dmisc31 = (84 / 2)*0.5;
15346 }
15347 190 }
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15349 {
15350
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15351 {
15352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15353 105 else dmisc32 = (84 / 3);
15354 105 }
15355 else
15356 {
15357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15358 85 else dmisc32 = (84 / 2)*0.25;
15359 }
15360 190 }
15361
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15362 190 }
15363
15364 161885 bool ePatra::animate(int32_t index)
15365 {
15366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15367
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15368 {
15369
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15370 {
15371 72 auto segment = (enemy*)guys.spr(i);
15372
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15373 72 segment->hp = -1000;
15374 72 }
15375
15376 1444 return Dead(index);
15377 }
15378
15379 160441 double basesize = 84;
15380
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15381 160441 double halfsize = basesize / 2;
15382 160441 double quartersize = halfsize / 2;
15383 160441 double twothirdsize = (basesize / 3)*2;
15384 160441 double onethirdsize = (basesize / 3);
15385
15386
15387
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15388 {
15389 36934 removearmos(x,y);
15390 36934 }
15391
15392
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15393 {
15394
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15395
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15396
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15397 {
15398 1797 clk2=0;
15399
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15400 {
15401
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15402 932 --loopcnt;
15403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15404 {
15405
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15406 {
15407
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15408 356 else loopcnt=dmisc7;
15409 356 }
15410 865 }
15411 else if (loopcnt == -1) loopcnt=dmisc7;
15412 else ++loopcnt;
15413
15414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15415 1797 }
15416 else
15417 {
15418 loopcnt = 0;
15419 misc = 1;
15420 }
15421 1797 }
15422 160441 }
15423
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15424
15425
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15426 {
15427 if (dmisc5 == 1 || dmisc5 == 3)
15428 {
15429 if (get_qr(qr_NEWENEMYTILES))
15430 {
15431 if (clk7 <= 0 || clk6 != -16) ++clk6;
15432 if (clk6 == 0) o_tile=d->e_tile;
15433 else
15434 {
15435 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15436 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15437 }
15438 }
15439 else clk6 = 0;
15440 }
15441 }
15442
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15443
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15444
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15445
15446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15447
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15448
15449
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15450 {
15451 //outside ring
15452
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15453 {
15454
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15455 {
15456 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15457 1152 enemy *s = ((enemy*)guys.spr(i));
15458 1152 s->setParent(this);
15459 1152 }
15460 else
15461 {
15462 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15463 192 enemy *s = ((enemy*)guys.spr(i));
15464 192 s->setParent(this);
15465 }
15466
15467 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15468 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15469 1344 }
15470
15471
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15472 {
15473
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15474 {
15475 2889 guys.swap(j,j+1);
15476 2889 }
15477
15478
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15479 764 }
15480 else
15481 {
15482 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15483
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15484
15485
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15486 {
15487 //maybe playing_field_offset here?
15488
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15489 {
15490
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15491
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15492 237330 }
15493 else
15494 {
15495 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15496 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15497 }
15498
15499 447583 temp_x=guys.spr(i)->x;
15500 447583 temp_y=guys.spr(i)->y;
15501 447583 }
15502 else //Oval
15503 {
15504 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15505 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15506
15507
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15508 {
15509 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15510
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15511 121041 }
15512 else
15513 {
15514 90996 guys.spr(i)->x = circle_x;
15515 90996 guys.spr(i)->y = circle_y;
15516 }
15517
15518 212037 temp_x=circle_x;
15519 212037 temp_y=circle_y;
15520 }
15521
15522 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15523 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15524
15525
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15526 {
15527 83117 guys.spr(i)->dir=l_down;
15528 83117 }
15529
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15530 {
15531 83568 guys.spr(i)->dir=left;
15532 83568 }
15533
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15534 {
15535 82454 guys.spr(i)->dir=l_up;
15536 82454 }
15537
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15538 {
15539 82188 guys.spr(i)->dir=up;
15540 82188 }
15541
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15542 {
15543 81600 guys.spr(i)->dir=r_up;
15544 81600 }
15545
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15546 {
15547 81993 guys.spr(i)->dir=right;
15548 81993 }
15549
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15550 {
15551 81699 guys.spr(i)->dir=r_down;
15552 81699 }
15553 else
15554 {
15555 83001 guys.spr(i)->dir=down;
15556 }
15557
15558 659620 guys.spr(i)->x += x;
15559 659620 guys.spr(i)->y += y;
15560 }
15561 660384 }
15562
15563
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15564 {
15565 32331 int timeneeded = 48;
15566 32331 int patbreath = (zc_oldrand()%50+50);
15567
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15568
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15569 {
15570 timeneeded = 48 + patbreath;
15571 }
15572
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15573 {
15574 timeneeded = 48 + 96;
15575 }
15576
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15577
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15578
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15579 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15580 249 && (clk6 >= 0) //if not in the middle of firing...
15581 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15582
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15583 {
15584
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15585 {
15586 case patratSTREAM:
15587 {
15588 clk7 = 97;
15589 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15590 else clk6 = 0;
15591 break;
15592 }
15593 case patratBREATH:
15594 {
15595 clk7 = patbreath;
15596 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15597 else clk6 = 0;
15598 break;
15599 }
15600 default:
15601 {
15602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15603 {
15604 clk6 = -48;
15605 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15606 }
15607 else
15608 {
15609 249 clk6 = 0;
15610
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15611 249 FirePatraWeapon();
15612 }
15613 249 break;
15614 }
15615 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15616 249 }
15617
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15618 {
15619 switch(dmisc28)
15620 {
15621 case patratSTREAM:
15622 {
15623 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15624 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15625 break;
15626 }
15627 case patratBREATH:
15628 {
15629 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15630 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15631 break;
15632 }
15633 default:
15634 {
15635 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15636 {
15637 FirePatraWeapon();
15638 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15639 }
15640 break;
15641 }
15642 }
15643 }
15644 32331 }
15645
15646 160441 int randattempts = 0;
15647 160441 int randeye = 0;
15648
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15649 {
15650 46240 do
15651 {
15652
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15653 46240 randeye += (index + flycnt + 1);
15654 46240 ++randattempts;
15655
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15656 46240 }
15657 160441 bool dofire = false;
15658
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15659 {
15660 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15661 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15662 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15663 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15664 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15665 {
15666 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15667 {
15668 if (clk5 >= dmisc19)
15669 {
15670 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15671 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15672 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15673 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15674 || dmisc18 == -1)
15675 dofire = true;
15676 }
15677 }
15678 }
15679 }
15680
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15681 {
15682
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15683 {
15684
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15685 {
15686 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15687
15688
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15689 {
15690
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15691 {
15692
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15693 {
15694 // Center eye shoots projectiles; make room for its firing tiles
15695 case 1:
15696 case 3:
15697 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15698 144 break;
15699
15700 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15701 default:
15702 case 2:
15703 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15704 168 break;
15705 }
15706 312 }
15707 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15708 312 }
15709 else
15710 {
15711 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15712 }
15713
15714 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15715
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15716 312 }
15717
15718
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15719 {
15720 263816 ((enemy*)guys.spr(i))->superman=true;
15721 263816 }
15722 else
15723 {
15724 70613 ((enemy*)guys.spr(i))->superman=false;
15725 }
15726
15727
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15728 {
15729
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15730 {
15731 269 guys.swap(j,j+1);
15732 269 }
15733
15734
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15735 145 }
15736 else
15737 {
15738 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15739
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15740
15741
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15742 {
15743
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15744 {
15745
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15746
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15747 168378 }
15748 else
15749 {
15750 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15751 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15752 }
15753
15754 327025 temp_x=guys.spr(i)->x;
15755 327025 temp_y=guys.spr(i)->y;
15756 327025 }
15757 else
15758 {
15759 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15760 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15761
15762
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15763 {
15764 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15765
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15766 3965 }
15767 else
15768 {
15769 3294 guys.spr(i)->x = circle_x;
15770 3294 guys.spr(i)->y = circle_y;
15771 }
15772
15773 7259 temp_x=circle_x;
15774 7259 temp_y=circle_y;
15775 }
15776
15777 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15778 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15779
15780
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15781 {
15782 41746 guys.spr(i)->dir=l_down;
15783 41746 }
15784
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15785 {
15786 41734 guys.spr(i)->dir=left;
15787 41734 }
15788
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15789 {
15790 41742 guys.spr(i)->dir=l_up;
15791 41742 }
15792
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15793 {
15794 41758 guys.spr(i)->dir=up;
15795 41758 }
15796
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15797 {
15798 41830 guys.spr(i)->dir=r_up;
15799 41830 }
15800
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15801 {
15802 41824 guys.spr(i)->dir=right;
15803 41824 }
15804
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15805 {
15806 41852 guys.spr(i)->dir=r_down;
15807 41852 }
15808 else
15809 {
15810 41798 guys.spr(i)->dir=down;
15811 }
15812
15813 334284 guys.spr(i)->x += x;
15814 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15815
15816
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15817 {
15818 /*
15819 if(!(zc_oldrand()&127))
15820 {
15821 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15822 sfx(wpnsfx(wpn),pan(x));
15823 }
15824 */
15825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15826 {
15827 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15828 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15829 {
15830 if (dmisc5 == 3)
15831 {
15832 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15833 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15834 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15835 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15836 }
15837 else
15838 {
15839 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15840 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15841 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15842 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15843 }
15844 }
15845 else
15846 {
15847 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15848 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15850 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15851 }
15852 }
15853
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15854
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15855
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15856 {
15857
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15858 {
15859 case 4: //Single one rapidfires
15860 {
15861 if (dofire && i == randeye)
15862 {
15863 ((esPatra*)guys.spr(i))->clk5 = -16;
15864 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15865 ((esPatra*)guys.spr(i))->clk4 = 96;
15866 clk5 = -3;
15867 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15868 }
15869 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15870 {
15871 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15872 sfx(wpnsfx(wpn),pan(x));
15873 }
15874 break;
15875 }
15876 case 3: //Ring
15877 {
15878 if (dofire)
15879 {
15880 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15881 {
15882 ((esPatra*)guys.spr(i))->clk5 = -48;
15883 clk5 = -48;
15884 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15885 }
15886 else
15887 {
15888 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15889 sfx(wpnsfx(wpn),pan(x));
15890 int32_t m=Ewpns.Count()-1;
15891 weapon *ew = (weapon*)(Ewpns.spr(m));
15892
15893 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15894 ((esPatra*)guys.spr(i))->clk5 = 0;
15895 clk5 = 0;
15896 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15897 }
15898 }
15899 if (((esPatra*)guys.spr(i))->clk5 == -16)
15900 {
15901 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15902 sfx(wpnsfx(wpn),pan(x));
15903 int32_t m=Ewpns.Count()-1;
15904 weapon *ew = (weapon*)(Ewpns.spr(m));
15905
15906 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15907 }
15908 break;
15909 }
15910 case 2: //one after another
15911 {
15912 if (dofire)
15913 {
15914 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15915 clk5 = -48 - (12*flycnt2);
15916 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15917 }
15918 if (((esPatra*)guys.spr(i))->clk5 == -16)
15919 {
15920 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15921 sfx(wpnsfx(wpn),pan(x));
15922 }
15923 break;
15924 }
15925 case 1: //random one eye
15926 {
15927 if (dofire && i == randeye)
15928 {
15929 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15930 {
15931 ((esPatra*)guys.spr(i))->clk5 = -48;
15932 clk5 = -48;
15933 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15934 }
15935 else
15936 {
15937 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15938 sfx(wpnsfx(wpn),pan(x));
15939 ((esPatra*)guys.spr(i))->clk5 = 0;
15940 clk5 = 0;
15941 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15942 }
15943 }
15944 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15945 {
15946 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15947 sfx(wpnsfx(wpn),pan(x));
15948 }
15949 break;
15950 }
15951 default: //old behavior, all eyes can fire any time
15952 {
15953
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15954
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15956 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15957 {
15958
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15959 {
15960 ((esPatra*)guys.spr(i))->clk5 = -48;
15961 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15962 }
15963 else
15964 {
15965 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15966 1155 sfx(wpnsfx(wpn),pan(x));
15967 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15968
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15969 }
15970 1155 }
15971
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15972 {
15973 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15974 sfx(wpnsfx(wpn),pan(x));
15975 }
15976 145268 break;
15977 }
15978 }
15979 145268 }
15980 145268 }
15981
15982 }
15983 334429 }
15984 46240 }
15985
15986 160441 adjusted=true;
15987 160441 return enemy::animate(index);
15988 161885 }
15989
15990 249 void ePatra::FirePatraWeapon()
15991 { //.707
15992 249 int32_t xoff = 0;
15993 249 int32_t yoff = 0;
15994
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
15995 {
15996 xoff += hxofs;
15997 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
15998 xoff += (hit_width / 2) - (weap_data.tilew * 8);
15999 else
16000 xoff += (hit_width / 2) - 8;
16001 }
16002
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16003 {
16004 yoff += hyofs;
16005 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16006 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16007 else
16008 yoff += (hit_height / 2) - 8;
16009 }
16010 249 sfx(wpnsfx(wpn),pan(x));
16011 // TODO(crash): check that .add succeeds.
16012
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16013 {
16014 case patrat8SHOT: //Fire Wizzrobe
16015 case patrat4SHOTDIAG:
16016 case patrat4SHOTRAND:
16017 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16018 {
16019 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16021 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16022 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16023
16024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16027 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16028
16029 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16030 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16032 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16033
16034 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16037 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16038
16039 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16040 }
16041
16042 [[fallthrough]];
16043 case patrat4SHOTCARD: //Stalfos 3
16044 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16047 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16048 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16049 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16050 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16051 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16053 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16054 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16055 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16056 break;
16057
16058 default:
16059 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16060
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16061 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16062
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16063
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16064 {
16065 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16066 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16068 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16069 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16072 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16073 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16074 {
16075 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16076 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16077 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16078 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16079 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16080 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16082 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16083 }
16084 }
16085 249 break;
16086
16087 }
16088 249 sfx(wpnsfx(wpn),pan(x));
16089 //+0.46364761
16090 //11.80
16091 249 }
16092
16093 324242 void ePatra::draw(BITMAP *dest)
16094 {
16095 324242 tile=o_tile;
16096 324242 update_enemy_frame();
16097 324242 enemy::draw(dest);
16098 324242 }
16099
16100 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16101 {
16102 int32_t ret = enemy::defend(wpnId, power, edef);
16103
16104 if(ret < 0 && (flycnt||flycnt2))
16105 return 0;
16106
16107 return ret;
16108 }
16109
16110 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16111 {
16112 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16113
16114
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16115 1281 return 0;
16116
16117 452 return ret;
16118 1733 }
16119
16120 190 void ePatra::init_size_flags() {
16121 190 SIZEflags = d->SIZEflags;
16122
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16123
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16124 // al_trace("Enemy txsz:%i\n", txsz);
16125
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16126
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16127
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16128
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16132
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16133
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16134 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16136
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16138 {
16139 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16140 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16141 }
16142
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16143
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16144
16145
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16146
16147 190 }
16148
16149 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16150 1656 {
16151 //cs=8;
16152
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16153 1656 item_set=0;
16154 1656 misc=clk;
16155 1656 clk4 = 0;
16156 1656 clk5 = 0;
16157 1656 clk = -((misc*21)>>1)-1;
16158
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16159 1656 hit_width=12;
16160 1656 hit_height=12;
16161 1656 hxofs=2;
16162 1656 hyofs=2;
16163 1656 extend = 0;
16164 1656 txsz = 1;
16165 1656 tysz = 1;
16166 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16167 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16168 int32_t prntSIZEflags = prntenemy->SIZEflags;
16169 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16170 // al_trace("Enemy txsz:%i\n", txsz);
16171 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16172 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16173 else
16174 hxsz=12;
16175 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16176 else
16177 hysz=12;
16178 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16179 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16180 else
16181 hxofs=2;
16182 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16183 else hyofs=2;
16184 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16185 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16186 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16187 {
16188 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16189 }
16190
16191 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16192 */
16193 1656 mainguy=count_enemy=false;
16194 1656 bgsfx=-1;
16195 //o_tile=0;
16196
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16197 1656 deadsfx = WAV_EDEAD;
16198 1656 hitsfx = WAV_EHIT;
16199 1656 isCore = false;
16200 1656 }
16201
16202 1010584 bool esPatra::animate(int32_t index)
16203 {
16204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16205
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16206 15160 return Dead(index);
16207
16208 995424 return enemy::animate(index);
16209 1010584 }
16210
16211 2028196 void esPatra::draw(BITMAP *dest)
16212 {
16213
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16214 {
16215 1721294 tile = o_tile+(clk&3);
16216
16217
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16218 {
16219 case up: //u
16220 214278 flip=0;
16221 214278 break;
16222
16223 case down: //d
16224 217924 flip=0;
16225 217924 tile+=4;
16226 217924 break;
16227
16228 case left: //l
16229 215346 flip=0;
16230 215346 tile+=8;
16231 215346 break;
16232
16233 case right: //r
16234 215726 flip=0;
16235 215726 tile+=12;
16236 215726 break;
16237
16238 case l_up: //ul
16239 213062 flip=0;
16240 213062 tile+=20;
16241 213062 break;
16242
16243 case r_up: //ur
16244 214350 flip=0;
16245 214350 tile+=24;
16246 214350 break;
16247
16248 case l_down: //dl
16249 215734 flip=0;
16250 215734 tile+=28;
16251 215734 break;
16252
16253 case r_down: //dr
16254 214874 flip=0;
16255 214874 tile+=32;
16256 214874 break;
16257 }
16258 1721294 }
16259 else
16260 {
16261 306902 tile = o_tile+((clk&2)>>1);
16262 }
16263
16264
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16265 1913340 enemy::draw(dest);
16266 2028196 }
16267
16268
16269 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16270 102 {
16271 102 adjusted=false;
16272
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16273
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16274 102 clk4 = 0;
16275 102 clk5 = 0;
16276 //flycnt=6; flycnt2=0;
16277 102 flycnt=dmisc1;
16278 102 flycnt2=0; // PatraBS doesn't have inner rings!
16279 102 loopcnt=0;
16280
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16282
16283 //nets+4480;
16284 102 }
16285
16286 35963 bool ePatraBS::animate(int32_t index)
16287 {
16288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16289
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16290 240 return Dead(index);
16291
16292
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16293 {
16294 4018 removearmos(x,y);
16295 4018 }
16296
16297 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16298
16299
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16300 {
16301 336 clk2=0;
16302
16303
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16304 177 --loopcnt;
16305 else
16306 {
16307
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16308 84 loopcnt=dmisc7;
16309 }
16310
16311 336 ++misc;
16312 336 }
16313
16314 // double size=1;;
16315
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16316 {
16317
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16318 {
16319 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16320
16321
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16322 {
16323 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16324 612 }
16325 else
16326 {
16327 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16328 }
16329
16330 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16331 612 }
16332
16333
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16334 {
16335
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16336 {
16337 131 guys.swap(j,j+1);
16338 131 }
16339
16340 104 --flycnt;
16341 104 }
16342 else
16343 {
16344 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16345
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16346 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16347 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16348
16349
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16350 {
16351 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16352
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16353 77643 }
16354 else
16355 {
16356 75725 guys.spr(i)->x = temp_x;
16357 75725 guys.spr(i)->y = temp_y;
16358 }
16359
16360 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16361 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16362
16363
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16364 {
16365 18812 guys.spr(i)->dir=l_down;
16366 18812 }
16367
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16368 {
16369 18839 guys.spr(i)->dir=left;
16370 18839 }
16371
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16372 {
16373 18802 guys.spr(i)->dir=l_up;
16374 18802 }
16375
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16376 {
16377 20143 guys.spr(i)->dir=up;
16378 20143 }
16379
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16380 {
16381 18517 guys.spr(i)->dir=r_up;
16382 18517 }
16383
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16384 {
16385 18779 guys.spr(i)->dir=right;
16386 18779 }
16387
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16388 {
16389 18992 guys.spr(i)->dir=r_down;
16390 18992 }
16391 else
16392 {
16393 20484 guys.spr(i)->dir=down;
16394 }
16395
16396 153368 guys.spr(i)->x += x;
16397 153368 guys.spr(i)->y += y;
16398 }
16399 153472 }
16400
16401 35723 adjusted=true;
16402 35723 return enemy::animate(index);
16403 35963 }
16404
16405 72874 void ePatraBS::draw(BITMAP *dest)
16406 {
16407 72874 tile=o_tile;
16408
16409
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16410 {
16411 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16412 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16413
16414
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16415 {
16416 19146 lookat=l_down;
16417 19146 }
16418
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16419 {
16420 18298 lookat=down;
16421 18298 }
16422
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16423 {
16424 13624 lookat=r_down;
16425 13624 }
16426
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16427 {
16428 7492 lookat=right;
16429 7492 }
16430
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16431 {
16432 1170 lookat=r_up;
16433 1170 }
16434
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16435 {
16436 964 lookat=up;
16437 964 }
16438
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16439 {
16440 1700 lookat=l_up;
16441 1700 }
16442 else
16443 {
16444 10480 lookat=left;
16445 }
16446
16447
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16448 {
16449 case up: //u
16450 964 flip=0;
16451 964 break;
16452
16453 case down: //d
16454 18298 flip=0;
16455 18298 tile+=8;
16456 18298 break;
16457
16458 case left: //l
16459 10480 flip=0;
16460 10480 tile+=40;
16461 10480 break;
16462
16463 case right: //r
16464 7492 flip=0;
16465 7492 tile+=48;
16466 7492 break;
16467
16468 case l_up: //ul
16469 1700 flip=0;
16470 1700 tile+=80;
16471 1700 break;
16472
16473 case r_up: //ur
16474 1170 flip=0;
16475 1170 tile+=88;
16476 1170 break;
16477
16478 case l_down: //dl
16479 19146 flip=0;
16480 19146 tile+=120;
16481 19146 break;
16482
16483 case r_down: //dr
16484 13624 flip=0;
16485 13624 tile+=128;
16486 13624 break;
16487 }
16488
16489 72874 tile+=(2*(clk&3));
16490 72874 xofs-=8;
16491 72874 yofs-=8;
16492 72874 drawblock(dest,15);
16493 72874 xofs+=8;
16494 72874 yofs+=8;
16495 72874 }
16496 else
16497 {
16498 flip=(clk&1);
16499 xofs-=8;
16500 yofs-=8;
16501 enemy::draw(dest);
16502 xofs+=16;
16503 enemy::draw(dest);
16504 yofs+=16;
16505 enemy::draw(dest);
16506 xofs-=16;
16507 enemy::draw(dest);
16508 xofs+=8;
16509 yofs-=8;
16510 }
16511 72874 }
16512
16513 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16514 {
16515 int32_t ret = enemy::defend(wpnId, power, edef);
16516
16517 if(ret < 0 && (flycnt||flycnt2))
16518 return 0;
16519
16520 return ret;
16521 }
16522
16523 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16524 {
16525 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16526
16527
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16528 81 return 0;
16529
16530 61 return ret;
16531 142 }
16532
16533 102 void ePatraBS::init_size_flags()
16534 {
16535 102 SIZEflags = d->SIZEflags;
16536
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16537 // al_trace("Enemy txsz:%i\n", txsz);
16538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16540 102 else hit_width = 32;
16541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16544 102 else hxofs = -8;
16545
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16546 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16547
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16548
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16549 {
16550 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16551 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16552 }
16553
16554
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16555 102 }
16556
16557 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16558 612 {
16559 //cs=csBOSS;
16560
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16561 612 item_set=0;
16562 612 misc=clk;
16563 612 clk = -((misc*21)>>1)-1;
16564 612 clk4 = 0;
16565 612 clk5 = 0;
16566
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16567 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16568
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16569 // al_trace("Enemy txsz:%i\n", txsz);
16570
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16572 612 else hit_width=16;
16573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16574 612 else hit_height=16;
16575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16576
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16578 612 else hyofs=2;
16579 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16580
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16582 {
16583 yofs = (int32_t)prntenemy->yofs;
16584 }
16585
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16586
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16587
16588 612 bgsfx=-1;
16589 612 mainguy=count_enemy=false;
16590 612 deadsfx = WAV_EDEAD;
16591 612 hitsfx = WAV_EHIT;
16592
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16593 612 isCore = false;
16594 612 }
16595
16596 155090 bool esPatraBS::animate(int32_t index)
16597 {
16598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16599
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16600 1552 return Dead(index);
16601
16602 153538 return enemy::animate(index);
16603 155090 }
16604
16605 315868 void esPatraBS::draw(BITMAP *dest)
16606 {
16607 315868 tile=o_tile;
16608
16609
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16610 {
16611
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16612 {
16613 case up: //u
16614 41612 flip=0;
16615 41612 break;
16616
16617 case down: //d
16618 42622 flip=0;
16619 42622 tile+=4;
16620 42622 break;
16621
16622 case left: //l
16623 37916 flip=0;
16624 37916 tile+=8;
16625 37916 break;
16626
16627 case right: //r
16628 38458 flip=0;
16629 38458 tile+=12;
16630 38458 break;
16631
16632 case l_up: //ul
16633 38564 flip=0;
16634 38564 tile+=20;
16635 38564 break;
16636
16637 case r_up: //ur
16638 38568 flip=0;
16639 38568 tile+=24;
16640 38568 break;
16641
16642 case l_down: //dl
16643 38662 flip=0;
16644 38662 tile+=28;
16645 38662 break;
16646
16647 case r_down: //dr
16648 39466 flip=0;
16649 39466 tile+=32;
16650 39466 break;
16651 }
16652
16653 315868 tile += ((clk&6)>>1);
16654 315868 }
16655 else
16656 {
16657 tile += (clk&4)?1:0;
16658 }
16659
16660
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16661 283752 enemy::draw(dest);
16662 315868 }
16663
16664 257619 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16665 {
16666
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106871 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257619 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16667
4/8
✓ Branch 0 taken 257619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257619 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257619 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257619 times.
✗ Branch 7 not taken.
257619 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16668
1/2
✓ Branch 0 taken 257619 times.
✗ Branch 1 not taken.
257619 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16669 257619 }
16670
16671 74710 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16672 {
16673 // Kludge
16674
4/8
✓ Branch 0 taken 74710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74710 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74710 times.
✗ Branch 7 not taken.
74710 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16675 74710 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74710 times.
74710 delete w;
16677 74710 return ret;
16678 }
16679
16680 9214 void enemy_scored(int32_t index)
16681 {
16682 9214 ((enemy*)guys.spr(index))->scored=true;
16683 9214 }
16684
16685 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16686 {
16687
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16688
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16689 765 g->y += 1;
16690
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16691 {
16692 4 g->o_tile = parentscr->guytile;
16693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16694 4 g->flags &= ~guy_invisible;
16695 4 g->cs = parentscr->guycs;
16696 4 }
16697 2191 guys.add(g);
16698 2191 }
16699
16700 23701 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16701 {
16702
4/8
✓ Branch 0 taken 23701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23701 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23701 times.
✗ Branch 7 not taken.
23701 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16703 23701 items.add(i);
16704 23701 }
16705
16706 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16707 {
16708
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16709 150 items.add(i);
16710 150 }
16711
16712 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16713 {
16714
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16715 3 items.add(i);
16716 3 }
16717
16718 19326 void add_item_for_screen(int32_t screen, item* item)
16719 {
16720 19326 item->screen_spawned = screen;
16721 19326 items.add(item);
16722 19326 }
16723
16724 96 void kill_em_all()
16725 {
16726
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16727 {
16728 353 enemy *e = ((enemy*)guys.spr(i));
16729
16730
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16731
16732 323 e->kickbucket();
16733 323 }
16734 96 }
16735
16736 bool can_kill_em_all()
16737 {
16738 for(int32_t i=0; i<guys.Count(); i++)
16739 {
16740 enemy *e = ((enemy*)guys.spr(i));
16741
16742 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16743 if(e->superman) continue;
16744 return true;
16745 }
16746 return false;
16747 }
16748
16749 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16750 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16751 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16752 {
16753 for(int32_t i=0; i<guys.Count(); i++)
16754 {
16755 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16756 {
16757 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16758 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16759 {
16760 return i;
16761 }
16762 }
16763 }
16764
16765 return -1;
16766 }
16767
16768 13162601 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16769 {
16770
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13146090 times.
✓ Branch 2 taken 33818802 times.
✓ Branch 3 taken 13131622 times.
46950424 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16771 {
16772
2/2
✓ Branch 0 taken 30979 times.
✓ Branch 1 taken 33787823 times.
33818802 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16773 {
16774 30979 return i;
16775 }
16776 33787823 }
16777
16778 13131622 return -1;
16779 13162601 }
16780
16781 // For Hero's hit detection. Count them if they are dying.
16782 52508 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16783 {
16784 52508 enemy *e = (enemy*)guys.spr(index);
16785
3/4
✓ Branch 0 taken 52508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28055 times.
✓ Branch 3 taken 24453 times.
52508 if(!e || e->hp > 0)
16786 28055 return -1;
16787
16788 24453 bool d = e->dying;
16789 24453 int32_t hc = e->hclk;
16790 24453 e->dying = false;
16791 24453 e->hclk = 0;
16792 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16793 24453 e->dying = d;
16794 24453 e->hclk = hc;
16795
16796
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16797 52508 }
16798
16799 14680516 bool hasMainGuy(int screen)
16800 {
16801
2/2
✓ Branch 0 taken 15979810 times.
✓ Branch 1 taken 5956407 times.
21936217 for(int32_t i=0; i<guys.Count(); i++)
16802 {
16803 15979810 enemy* e = (enemy*)guys.spr(i);
16804
4/4
✓ Branch 0 taken 15516726 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 8724109 times.
✓ Branch 3 taken 6792617 times.
15979810 if (e->screen_spawned == screen && e->mainguy)
16805 {
16806 8724109 return true;
16807 }
16808 7255701 }
16809
16810 5956407 return false;
16811 14680516 }
16812
16813 138 void EatHero(int32_t index)
16814 {
16815 138 ((eStalfos*)guys.spr(index))->eathero();
16816 138 }
16817
16818 9 void GrabHero(int32_t index)
16819 {
16820 9 ((eWallM*)guys.spr(index))->grabhero();
16821 9 }
16822
16823 1338 bool CarryHero()
16824 {
16825
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16826 {
16827
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16828 {
16829
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16830 {
16831 1338 Hero.x=guys.spr(i)->x;
16832 1338 Hero.y=guys.spr(i)->y;
16833 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16834 }
16835 505 }
16836
16837 // Like Likes currently can't carry Hero.
16838 /*
16839 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16840 {
16841 if(((eLikeLike*)guys.spr(i))->hashero)
16842 {
16843 Hero.x=guys.spr(i)->x;
16844 Hero.y=guys.spr(i)->y;
16845 return (true);
16846 }
16847 }*/
16848 2595 }
16849
16850 return false;
16851 1338 }
16852
16853 // Move item with guy
16854 void movefairy(zfix &x,zfix &y,int32_t misc)
16855 {
16856 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16857
16858 if(i!=-1)
16859 {
16860 x = guys.spr(i)->x;
16861 y = guys.spr(i)->y;
16862 }
16863 }
16864
16865 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16866 void movefairy2(zfix x,zfix y,int32_t misc)
16867 {
16868 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16869
16870 if(i!=-1)
16871 {
16872 guys.spr(i)->x = x;
16873 guys.spr(i)->y = y;
16874 }
16875 }// Move item with guy
16876
16877 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16878 {
16879 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16880
16881
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16882 {
16883 60788 x = fairy->x;
16884 60788 y = fairy->y;
16885 60788 }
16886 60788 }
16887
16888 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16889 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16890 {
16891 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16892
16893
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16894 {
16895 404 fairy->x = x;
16896 404 fairy->y = y;
16897 404 }
16898 404 }
16899
16900 void killfairy(int32_t misc)
16901 {
16902 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16903 guys.del(i);
16904 }
16905
16906 219 int32_t getGuyIndex(const int32_t eid)
16907 {
16908
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16909 {
16910
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16911 219 return i;
16912 609 }
16913
16914 return -1;
16915 219 }
16916
16917 219 void killfairynew(item const &itemfairy)
16918 {
16919 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16920
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16921 219 }
16922
16923 //Should probably change this to return an 'enemy*', null on failure -Em
16924 21822 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16925 {
16926 21822 return addenemy_z(screen,x,y,0,id,clk);
16927 }
16928
16929 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16930 {
16931 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16932 }
16933
16934 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16935 {
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16937
16938 1997 int32_t ret = 0;
16939 1997 sprite *e=NULL;
16940
16941
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16942 {
16943 //Fixme: possible enemy memory leak. (minor)
16944 case eeWALK:
16945
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16946 110 break;
16947
16948 case eeLEV:
16949 e = new eLeever((zfix)x,(zfix)y,id,clk);
16950 break;
16951
16952 case eeTEK:
16953 e = new eTektite((zfix)x,(zfix)y,id,clk);
16954 break;
16955
16956 case eePEAHAT:
16957 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16958 break;
16959
16960 case eeZORA:
16961 e = new eZora((zfix)x,(zfix)y,id,clk);
16962 break;
16963
16964 case eeGHINI:
16965 e = new eGhini((zfix)x,(zfix)y,id,clk);
16966 break;
16967
16968 case eeKEESE:
16969
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16970 1865 break;
16971
16972 case eeWIZZ:
16973
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16974 15 break;
16975
16976 case eePROJECTILE:
16977 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16978 break;
16979
16980 case eeWALLM:
16981 e = new eWallM((zfix)x,(zfix)y,id,clk);
16982 break;
16983
16984 case eeAQUA:
16985 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
16986 break;
16987
16988 case eeMOLD:
16989 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16990 break;
16991
16992 case eeMANHAN:
16993
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
16994 1 break;
16995
16996 case eeGLEEOK:
16997 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16998 break;
16999
17000 case eeGHOMA:
17001 e = new eGohma((zfix)x,(zfix)y,id,clk);
17002 break;
17003
17004 case eeLANM:
17005 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17006 break;
17007
17008 case eeGANON:
17009 e = new eGanon((zfix)x,(zfix)y,id,clk);
17010 break;
17011
17012 case eeFAIRY:
17013 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17014 break;
17015
17016 case eeFIRE:
17017
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17018 2 break;
17019
17020 case eeOTHER:
17021 e = new eOther((zfix)x,(zfix)y,id,clk);
17022 break;
17023
17024
17025 case eeSCRIPT01:
17026 case eeSCRIPT02:
17027 case eeSCRIPT03:
17028 case eeSCRIPT04:
17029 case eeSCRIPT05:
17030 case eeSCRIPT06:
17031 case eeSCRIPT07:
17032 case eeSCRIPT08:
17033 case eeSCRIPT09:
17034 case eeSCRIPT10:
17035 case eeSCRIPT11:
17036 case eeSCRIPT12:
17037 case eeSCRIPT13:
17038 case eeSCRIPT14:
17039 case eeSCRIPT15:
17040 case eeSCRIPT16:
17041 case eeSCRIPT17:
17042 case eeSCRIPT18:
17043 case eeSCRIPT19:
17044 case eeSCRIPT20:
17045 {
17046 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17047 {
17048 e = new eScript((zfix)x,(zfix)y,id,clk);
17049 break;
17050 }
17051 else return 0;
17052 }
17053
17054 case eeFFRIENDLY01:
17055 case eeFFRIENDLY02:
17056 case eeFFRIENDLY03:
17057 case eeFFRIENDLY04:
17058 case eeFFRIENDLY05:
17059 case eeFFRIENDLY06:
17060 case eeFFRIENDLY07:
17061 case eeFFRIENDLY08:
17062 case eeFFRIENDLY09:
17063 case eeFFRIENDLY10:
17064 {
17065 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17066 {
17067 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17068 }
17069 else return 0;
17070
17071 }
17072
17073 case eeSPINTILE:
17074 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17075 break;
17076
17077 // and these enemies use the misc10/misc2 value
17078 case eeROCK:
17079 {
17080 switch(guysbuf[id&0xFFF].attributes[9])
17081 {
17082 case 1:
17083 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17084 break;
17085
17086 case 0:
17087 default:
17088 e = new eRock((zfix)x,(zfix)y,id,clk);
17089 break;
17090 }
17091
17092 break;
17093 }
17094
17095 case eeTRAP:
17096 {
17097 switch(guysbuf[id&0xFFF].attributes[1])
17098 {
17099 case 1:
17100 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17101 break;
17102
17103 case 0:
17104 default:
17105 e = new eTrap((zfix)x,(zfix)y,id,clk);
17106 break;
17107 }
17108
17109 break;
17110 }
17111
17112 case eeDONGO:
17113 {
17114 switch(guysbuf[id&0xFFF].attributes[9])
17115 {
17116 case 1:
17117 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17118 break;
17119
17120 case 0:
17121 default:
17122 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17123 break;
17124 }
17125
17126 break;
17127 }
17128
17129 case eeDIG:
17130 {
17131
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17132 {
17133 case 1:
17134 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17135 break;
17136
17137 4 case 0:
17138 default:
17139
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17140 4 break;
17141 }
17142
17143 4 break;
17144 }
17145
17146 case eePATRA:
17147 {
17148 switch(guysbuf[id&0xFFF].attributes[9])
17149 {
17150 case 1:
17151 if (get_qr(qr_HARDCODED_BS_PATRA))
17152 {
17153 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17154 break;
17155 }
17156 [[fallthrough]];
17157 case 0:
17158 default:
17159 e = new ePatra((zfix)x,(zfix)y,id,clk);
17160 break;
17161 }
17162
17163 break;
17164 }
17165
17166 case eeGUY:
17167 {
17168 switch(guysbuf[id&0xFFF].attributes[9])
17169 {
17170 case 1:
17171 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17172 break;
17173
17174 case 0:
17175 default:
17176 e = new eNPC((zfix)x,(zfix)y,id,clk);
17177 break;
17178 }
17179
17180 break;
17181 }
17182
17183 case eeNONE:
17184 if(guysbuf[id&0xFFF].attributes[9] ==1)
17185 {
17186 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17187 break;
17188 break;
17189 }
17190 [[fallthrough]];
17191 default:
17192
17193 return 0;
17194 }
17195
17196 1997 ret++; // Made one enemy.
17197
17198
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17199 {
17200 7 e->z = (zfix)z;
17201 7 }
17202
17203
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17204 1997 e->setParent(parent);
17205
17206
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17207 {
17208 return 0;
17209 }
17210
17211 // add segments of segmented enemies
17212 1997 int32_t c=0;
17213
17214
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17215 {
17216 case eeMOLD:
17217 {
17218 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17219 id &= 0xFFF;
17220
17221 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17222 {
17223 //christ this is messy -DD
17224 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17225
17226 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17227 {
17228 al_trace("Moldorm segment %d could not be created!\n",i+1);
17229
17230 for(int32_t j=0; j<i+1; j++)
17231 guys.del(guys.Count()-1);
17232
17233 return 0;
17234 }
17235
17236 if(i>0)
17237 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17238
17239 ret++;
17240 }
17241
17242 break;
17243 }
17244
17245 case eeLANM:
17246 {
17247 id &= 0xFFF;
17248 int32_t shft = guysbuf[id].attributes[1];
17249 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17250
17251 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17252 {
17253 al_trace("Lanmola segment 1 could not be created!\n");
17254 guys.del(guys.Count()-1);
17255 return 0;
17256 }
17257
17258 ret++;
17259
17260 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17261 {
17262 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17263 {
17264 al_trace("Lanmola segment %d could not be created!\n",i+1);
17265
17266 for(int32_t j=0; j<i+1; j++)
17267 guys.del(guys.Count()-1);
17268
17269 return 0;
17270 }
17271
17272 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17273 ret++;
17274 }
17275 }
17276 break;
17277
17278 case eeMANHAN:
17279 1 id &= 0xFFF;
17280
17281
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17282 {
17283
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17284 {
17285 al_trace("Manhandla head %d could not be created!\n",i+1);
17286
17287 for(int32_t j=0; j<i+1; j++)
17288 {
17289 guys.del(guys.Count()-1);
17290 }
17291
17292 return 0;
17293 }
17294
17295 4 ret++;
17296 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17297 4 }
17298
17299 1 break;
17300
17301 case eeGLEEOK:
17302 {
17303 id &= 0xFFF;
17304
17305 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17306 {
17307 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17308 {
17309 al_trace("Gleeok head %d could not be created!\n",i+1);
17310
17311 for(int32_t j=0; j<i+1; j++)
17312 {
17313 guys.del(guys.Count()-1);
17314 }
17315
17316 return false;
17317 }
17318
17319 c-=guysbuf[id].attributes[3];
17320 ret++;
17321 }
17322 }
17323 break;
17324
17325
17326 case eePATRA:
17327 {
17328 id &= 0xFFF;
17329 int32_t outeyes = 0;
17330
17331 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17332 {
17333 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17334 {
17335 al_trace("Patra outer eye %d could not be created!\n",i+1);
17336
17337 for(int32_t j=0; j<i+1; j++)
17338 guys.del(guys.Count()-1);
17339
17340 return 0;
17341 }
17342 else
17343 outeyes++;
17344
17345 ret++;
17346 }
17347
17348 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17349 {
17350 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17351 {
17352 al_trace("Patra inner eye %d could not be created!\n",i+1);
17353
17354 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17355 guys.del(guys.Count()-1);
17356
17357 return 0;
17358 }
17359
17360 ret++;
17361 }
17362
17363 break;
17364 }
17365 }
17366
17367
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17368 {
17369 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17370 2001 e->screen_spawned = screen;
17371 2001 }
17372
17373 1997 return ret;
17374 1997 }
17375
17376 // Returns number of enemies/segments created
17377 102142 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17378 {
17379 102142 int32_t realid = id&0xFFF;
17380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if( realid > MAXGUYS )
17381 {
17382 return 0;
17383 }
17384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if(id <= 0) return 0;
17385
17386 102142 int32_t ret = 0;
17387 102142 sprite *e=NULL;
17388
17389
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50147 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102142 switch(guysbuf[id&0xFFF].type)
17390 {
17391 //Fixme: possible enemy memory leak. (minor)
17392 case eeWALK:
17393
3/6
✓ Branch 0 taken 50147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50147 times.
✗ Branch 5 not taken.
50147 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17394 50147 break;
17395
17396 case eeLEV:
17397
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17398 3942 break;
17399
17400 case eeTEK:
17401
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17402 5212 break;
17403
17404 case eePEAHAT:
17405
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17406 1825 break;
17407
17408 case eeZORA:
17409
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17410 2797 break;
17411
17412 case eeGHINI:
17413
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17414 461 break;
17415
17416 case eeKEESE:
17417
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17418 11855 break;
17419
17420 case eeWIZZ:
17421
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17422 5335 break;
17423
17424 case eePROJECTILE:
17425
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17426 4429 break;
17427
17428 case eeWALLM:
17429
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17430 998 break;
17431
17432 case eeAQUA:
17433
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17434 126 break;
17435
17436 case eeMOLD:
17437
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17438 618 break;
17439
17440 case eeMANHAN:
17441
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17442 149 break;
17443
17444 case eeGLEEOK:
17445
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17446 168 break;
17447
17448 case eeGHOMA:
17449
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17450 93 break;
17451
17452 case eeLANM:
17453
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17454 420 break;
17455
17456 case eeGANON:
17457
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17458 13 break;
17459
17460 case eeFAIRY:
17461
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17462 732 break;
17463
17464 case eeFIRE:
17465
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17466 758 break;
17467
17468 case eeOTHER:
17469
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17470 7630 break;
17471
17472
17473 case eeSCRIPT01:
17474 case eeSCRIPT02:
17475 case eeSCRIPT03:
17476 case eeSCRIPT04:
17477 case eeSCRIPT05:
17478 case eeSCRIPT06:
17479 case eeSCRIPT07:
17480 case eeSCRIPT08:
17481 case eeSCRIPT09:
17482 case eeSCRIPT10:
17483 case eeSCRIPT11:
17484 case eeSCRIPT12:
17485 case eeSCRIPT13:
17486 case eeSCRIPT14:
17487 case eeSCRIPT15:
17488 case eeSCRIPT16:
17489 case eeSCRIPT17:
17490 case eeSCRIPT18:
17491 case eeSCRIPT19:
17492 case eeSCRIPT20:
17493 {
17494 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17495 {
17496 e = new eScript((zfix)x,(zfix)y,id,clk);
17497 break;
17498 }
17499 else return 0;
17500 }
17501
17502 case eeFFRIENDLY01:
17503 case eeFFRIENDLY02:
17504 case eeFFRIENDLY03:
17505 case eeFFRIENDLY04:
17506 case eeFFRIENDLY05:
17507 case eeFFRIENDLY06:
17508 case eeFFRIENDLY07:
17509 case eeFFRIENDLY08:
17510 case eeFFRIENDLY09:
17511 case eeFFRIENDLY10:
17512 {
17513 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17514 {
17515 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17516 }
17517 else return 0;
17518
17519 }
17520
17521 case eeSPINTILE:
17522
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17523 94 break;
17524
17525 // and these enemies use the misc10/misc2 value
17526 case eeROCK:
17527 {
17528
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17529 {
17530 case 1:
17531
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17532 30 break;
17533
17534 354 case 0:
17535 default:
17536
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17537 354 break;
17538 }
17539
17540 384 break;
17541 }
17542
17543 case eeTRAP:
17544 {
17545
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17546 {
17547 case 1:
17548
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17549 832 break;
17550
17551 1640 case 0:
17552 default:
17553
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17554 1640 break;
17555 }
17556
17557 2472 break;
17558 }
17559
17560 case eeDONGO:
17561 {
17562
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17563 {
17564 case 1:
17565
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17566 48 break;
17567
17568 203 case 0:
17569 default:
17570
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17571 203 break;
17572 }
17573
17574 251 break;
17575 }
17576
17577 case eeDIG:
17578 {
17579
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17580 {
17581 case 1:
17582
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17583 327 break;
17584
17585 76 case 0:
17586 default:
17587
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17588 76 break;
17589 }
17590
17591 403 break;
17592 }
17593
17594 case eePATRA:
17595 {
17596
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17597 {
17598 case 1:
17599
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17600 {
17601
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17602 102 break;
17603 }
17604 [[fallthrough]];
17605 190 case 0:
17606 default:
17607
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17608 190 break;
17609 }
17610
17611 292 break;
17612 }
17613
17614 case eeGUY:
17615 {
17616
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17617 {
17618 case 1:
17619 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17620 break;
17621
17622 5 case 0:
17623 default:
17624
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17625 5 break;
17626 }
17627
17628 5 break;
17629 }
17630
17631 case eeNONE:
17632
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17633 {
17634
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17635 533 break;
17636 }
17637 [[fallthrough]];
17638 default:
17639
17640 return 0;
17641 }
17642
17643 102142 ret++; // Made one enemy.
17644
17645
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101965 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102142 if(z && canfall(id))
17646 {
17647 152 e->z = (zfix)z;
17648 152 }
17649
17650
2/2
✓ Branch 0 taken 101965 times.
✓ Branch 1 taken 177 times.
102142 ((enemy*)e)->ceiling = (z && canfall(id));
17651
17652
1/2
✓ Branch 0 taken 102142 times.
✗ Branch 1 not taken.
102142 if(!guys.add(e))
17653 {
17654 return 0;
17655 }
17656
17657 // add segments of segmented enemies
17658 102142 int32_t c=0;
17659
17660
6/6
✓ Branch 0 taken 100495 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
102142 switch(guysbuf[id&0xFFF].type)
17661 {
17662 case eeMOLD:
17663 {
17664 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17665 618 id &= 0xFFF;
17666
17667
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17668 {
17669 //christ this is messy -DD
17670 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17671
17672
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17673 {
17674 al_trace("Moldorm segment %d could not be created!\n",i+1);
17675
17676 for(int32_t j=0; j<i+1; j++)
17677 guys.del(guys.Count()-1);
17678
17679 return 0;
17680 }
17681
17682
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17683 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17684
17685 3150 ret++;
17686 3150 }
17687
17688 618 break;
17689 }
17690
17691 case eeLANM:
17692 {
17693 420 id &= 0xFFF;
17694 420 int32_t shft = guysbuf[id].attributes[1];
17695 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17696
17697
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17698 {
17699 al_trace("Lanmola segment 1 could not be created!\n");
17700 guys.del(guys.Count()-1);
17701 return 0;
17702 }
17703
17704 420 ret++;
17705
17706
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17707 {
17708
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17709 {
17710 al_trace("Lanmola segment %d could not be created!\n",i+1);
17711
17712 for(int32_t j=0; j<i+1; j++)
17713 guys.del(guys.Count()-1);
17714
17715 return 0;
17716 }
17717
17718 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17719 1847 ret++;
17720 1847 }
17721 }
17722 420 break;
17723
17724 case eeMANHAN:
17725 149 id &= 0xFFF;
17726
17727
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17728 {
17729
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17730 {
17731 al_trace("Manhandla head %d could not be created!\n",i+1);
17732
17733 for(int32_t j=0; j<i+1; j++)
17734 {
17735 guys.del(guys.Count()-1);
17736 }
17737
17738 return 0;
17739 }
17740
17741 688 ret++;
17742 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17743 688 }
17744
17745 149 break;
17746
17747 case eeGLEEOK:
17748 {
17749 168 id &= 0xFFF;
17750 168 eGleeok* parent = (eGleeok*)e;
17751
17752
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17753 {
17754
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17755
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17756 {
17757 al_trace("Gleeok head %d could not be created!\n",i+1);
17758
17759 for(int32_t j=0; j<i+1; j++)
17760 {
17761 guys.del(guys.Count()-1);
17762 }
17763
17764 return false;
17765 }
17766
17767 533 head->necktile=parent->necktile;
17768 533 head->dummy_int[1]=parent->necktile;
17769
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17770 {
17771 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17772 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17773 421 }
17774 else
17775 {
17776 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17777 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17778 }
17779 533 head->tile = head->dummy_int[2];
17780
17781 533 c-=guysbuf[id].attributes[3];
17782 533 ret++;
17783 533 }
17784 }
17785 168 break;
17786
17787
17788 case eePATRA:
17789 {
17790 292 id &= 0xFFF;
17791 292 int32_t outeyes = 0;
17792
17793
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17794 {
17795
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17796 {
17797 al_trace("Patra outer eye %d could not be created!\n",i+1);
17798
17799 for(int32_t j=0; j<i+1; j++)
17800 guys.del(guys.Count()-1);
17801
17802 return 0;
17803 }
17804 else
17805 1956 outeyes++;
17806
17807 1956 ret++;
17808 1956 }
17809
17810
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17811 {
17812
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17813 {
17814 al_trace("Patra inner eye %d could not be created!\n",i+1);
17815
17816 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17817 guys.del(guys.Count()-1);
17818
17819 return 0;
17820 }
17821
17822 312 ret++;
17823 312 }
17824
17825 292 break;
17826 }
17827 }
17828
17829
2/2
✓ Branch 0 taken 111048 times.
✓ Branch 1 taken 102142 times.
213190 for (int i = 0; i < ret; i++)
17830 {
17831 111048 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17832 111048 e->screen_spawned = screen;
17833 111048 }
17834
17835 102142 return ret;
17836 102142 }
17837
17838 2059282 bool isjumper(int32_t id)
17839 {
17840
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17841 {
17842 return false;
17843 }
17844
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].type)
17845 {
17846 case eeROCK:
17847 case eeTEK:
17848 9 return true;
17849
17850 case eeWALK:
17851
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17852 93604 }
17853
17854 2047008 return false;
17855 2059282 }
17856
17857
17858 8068 bool isfixedtogrid(int32_t id)
17859 {
17860
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17861 {
17862 return false;
17863 }
17864
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17865 {
17866 case eeWALK:
17867 case eeLEV:
17868 case eeZORA:
17869 case eeDONGO:
17870 case eeGANON:
17871 case eeROCK:
17872 case eeGLEEOK:
17873 case eeAQUA:
17874 case eeLANM:
17875 return true;
17876 }
17877
17878 8068 return false;
17879 8068 }
17880
17881 // Can't fall, can have Z value.
17882 76161798 bool isflier(int32_t id)
17883 {
17884
3/4
✓ Branch 0 taken 76161798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 76050940 times.
76161798 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17885 {
17886 110858 return false;
17887 }
17888
2/2
✓ Branch 0 taken 14067022 times.
✓ Branch 1 taken 61983918 times.
76050940 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17889 {
17890 case eePEAHAT:
17891 case eeKEESE:
17892 case eePATRA:
17893 case eeFAIRY:
17894 case eeGHINI:
17895
17896 // Could theoretically have their Z set by a script
17897 case eeFIRE:
17898 14067022 return true;
17899 break;
17900 }
17901
17902 61983918 return false;
17903 76161798 }
17904
17905 // Can't have Z position
17906 4046103 bool never_in_air(int32_t id)
17907 {
17908
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17909 {
17910 return false;
17911 }
17912
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].type)
17913 {
17914 case eeMANHAN:
17915 case eeMOLD:
17916 case eeLANM:
17917 case eeGLEEOK:
17918 case eeZORA:
17919 case eeLEV:
17920 case eeAQUA:
17921 case eeROCK:
17922 case eeGANON:
17923 case eeTRAP:
17924 case eePROJECTILE:
17925 case eeSPINTILE:
17926 9550 return true;
17927 }
17928
17929 4036553 return false;
17930 4046103 }
17931
17932 2248208 bool canfall(int32_t id)
17933 {
17934
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17935 {
17936 46 return false;
17937 }
17938
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].type)
17939 {
17940 case eeGUY:
17941 {
17942
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17943 40 return false;
17944
17945 switch(guysbuf[id&0xFFF].attributes[9])
17946 {
17947 case 1:
17948 case 2:
17949 return true;
17950
17951 case 0:
17952 case 3:
17953 default:
17954 return false;
17955 }
17956
17957 case eeGHOMA:
17958 case eeDIG:
17959 return false;
17960 }
17961 }
17962
17963
17964
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17965 2248208 }
17966
17967 58289105 bool enemy::enemycanfall(int32_t id, bool checkgrav) const
17968 {
17969
3/4
✓ Branch 0 taken 58289105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 58199507 times.
58289105 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17970 {
17971 89598 return false;
17972 }
17973 //Z_scripterrlog("canfall family is %d:\n", family);
17974 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17975 //if ( family == eeFIRE && id >= eSTART )
17976 //{
17977 // Z_scripterrlog("eeFire\n");
17978 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17979 //}
17980
17981 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17982
17983
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 55693095 times.
✓ Branch 2 taken 2077477 times.
58199507 switch(guysbuf[id&0xFFF].type)
17984 {
17985 case eeGUY:
17986 {
17987
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
17988 2077477 return false;
17989
17990 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
17991 {
17992 case 1:
17993 case 2:
17994 return true;
17995
17996 case 0:
17997 case 3:
17998 default:
17999 return false;
18000 }
18001
18002 case eeGHOMA:
18003 case eeDIG:
18004 428935 return false;
18005 }
18006 }
18007
18008
2/2
✓ Branch 0 taken 39108925 times.
✓ Branch 1 taken 16584170 times.
55693095 if(!checkgrav) return true;
18009 39108925 return (moveflags & move_obeys_grav);
18010
18011 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18012 // {
18013 // if ( moveflags & move_obeys_grav ) return true;
18014 // else return false;
18015 // }
18016 // else
18017 // {
18018 // return (moveflags & move_obeys_grav);
18019 // }
18020 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18021 58289105 }
18022
18023 1271 void addfires()
18024 {
18025
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18026 {
18027 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18028 457 int32_t bs = get_qr(qr_BSZELDA);
18029 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18030 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18031 457 }
18032 1271 }
18033
18034 // This function runs one time for every screen on the first frame of a region being loaded.
18035 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18036 37031 static void loadguys(mapscr* scr)
18037 {
18038 37031 int screen = scr->screen;
18039 37031 byte Guy=0;
18040 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18041 // Else use mITEM and ipONETIME
18042 37031 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18043 37031 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18044
18045 37031 mapscr* guyscr = scr;
18046
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36125 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
37031 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18047 {
18048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18049 {
18050 431 Guy=special_warp_return_scr->guy;
18051 431 guyscr = special_warp_return_scr;
18052 431 }
18053 431 }
18054 else
18055 {
18056 36600 Guy=scr->guy;
18057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36600 times.
36600 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18058 36600 mark_visited(screen);
18059 }
18060
18061 114009 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18062
18063 37031 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18064 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18065
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33166 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
37031 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18066 {
18067
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18068 {
18069 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18070 11 guys.spr(0)->hxofs=1000;
18071 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18072 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18073 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18074 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18075 11 return;
18076 }
18077
18078
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18079
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18080 4 : (guyscr->roomflags&RFL_GUYFIRES);
18081
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18082 1271 addfires();
18083
18084
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18085
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18086 13 Guy=0;
18087
18088
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18089 {
18090 case rSP_ITEM:
18091 case rGRUMBLE:
18092 case rBOMBS:
18093 case rARROWS:
18094 case rSWINDLE:
18095 case rMUPGRADE:
18096 case rLEARNSLASH:
18097 case rTAKEONE:
18098
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18099 55 Guy=0;
18100
18101 167 break;
18102
18103 case rREPAIR:
18104 if (get_qr(qr_OLD_DOORREPAIR)) break;
18105 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18106 Guy=0;
18107
18108 break;
18109 case rRP_HC:
18110 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18111 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18112 Guy=0;
18113
18114 break;
18115 case rMONEY:
18116
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18117 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18118 Guy=0;
18119
18120 break;
18121
18122 case rTRIFORCE:
18123 {
18124 45 int32_t tc = TriforceCount();
18125
18126
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18127 {
18128
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18129 10 Guy=0;
18130 9 }
18131 else
18132 {
18133
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18134 33 Guy=0;
18135 }
18136 }
18137 43 break;
18138 }
18139
18140
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18141 {
18142
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18143 1162 blockpath=true;
18144
18145
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18146 783 sfx(WAV_SCALE);
18147
18148
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18149 1195 Hero.Freeze();
18150 1195 }
18151 1302 }
18152
5/6
✓ Branch 0 taken 33906 times.
✓ Branch 1 taken 1810 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33835 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1810 times.
35716 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18153 {
18154 71 sfx(WAV_SCALE);
18155 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18156 71 }
18157
18158 111054 loaditem(scr, dx, dy);
18159
18160 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18161 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18162
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36999 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
37018 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18163 {
18164
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18165 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18166 15 }
18167 37029 }
18168
18169 35787 void loadguys()
18170 {
18171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35787 times.
35787 if (loaded_guys)
18172 return;
18173
18174 35787 loaded_guys = true;
18175 35787 repaircharge = 0;
18176 35787 adjustmagic = false;
18177 35787 learnslash = false;
18178
2/2
✓ Branch 0 taken 107361 times.
✓ Branch 1 taken 35787 times.
143148 for (int32_t i=0; i<3; i++)
18179 {
18180 107361 prices[i] = 0;
18181 107361 }
18182
18183 72818 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18184 37031 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18185 37031 loadguys(scr);
18186 37031 });
18187 35787 }
18188
18189 37037 void loaditem(mapscr* scr, int offx, int offy)
18190 {
18191 37037 int screen = scr->screen;
18192 37037 byte Item = 0;
18193
18194
2/2
✓ Branch 0 taken 36131 times.
✓ Branch 1 taken 906 times.
37037 if(screen<128)
18195 {
18196 36131 Item=scr->item;
18197
18198
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 34538 times.
✓ Branch 2 taken 32913 times.
✓ Branch 3 taken 3218 times.
36131 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18199 {
18200
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3159 times.
3218 if(scr->flags8&fSECRETITEM)
18201 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18202
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1995 times.
3159 else if(scr->flags&fITEM)
18203 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18204
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1886 times.
1995 else if(scr->flags11&efCARRYITEM)
18205 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18206 else
18207 {
18208 1886 int x = scr->itemx;
18209
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1886 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18210 -170 :
18211 1886 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18212
3/6
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1886 times.
✗ Branch 5 not taken.
3772 add_item_for_screen(screen, new item(offx + x, offy + y,
18213
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1871 times.
✗ Branch 9 not taken.
1886 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18214
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1781 times.
1886 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18215 1886 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18216 }
18217 3218 }
18218 36131 }
18219
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18220 {
18221
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18222
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18223 {
18224 163 Item = special_warp_return_scr->catchall;
18225
18226
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18227 {
18228 162 int x = scr->itemx;
18229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18230 -170 :
18231 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18232
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18233
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18234 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18235 162 }
18236 163 }
18237 475 }
18238 37037 }
18239
18240 957 void never_return(int32_t screen, int32_t index)
18241 {
18242
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18243 191 goto doit;
18244
18245
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18246
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18247 {
18248 437 goto dontdoit;
18249 329 }
18250
18251 doit:
18252 520 setmapflag(get_scr(screen), mNEVERRET);
18253 dontdoit:
18254 957 return;
18255 }
18256
18257 63753 bool slowguy(int32_t id)
18258 {
18259
2/4
✓ Branch 0 taken 63753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63753 times.
63753 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18260 {
18261 return false;
18262 }
18263
18264 63753 id = id&0xFFF;
18265
18266
2/2
✓ Branch 0 taken 54110 times.
✓ Branch 1 taken 9643 times.
63753 switch(id)
18267 {
18268 case eOCTO1S:
18269 case eOCTO2S:
18270 case eOCTO1F:
18271 case eOCTO2F:
18272 case eLEV1:
18273 case eLEV2:
18274 case eROCK:
18275 case eBOULDER:
18276 9643 return true;
18277 }
18278
18279 54110 return false;
18280 63753 }
18281
18282 83364 static bool ok2add(mapscr* scr, int32_t id)
18283 {
18284
2/4
✓ Branch 0 taken 83364 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83364 times.
83364 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18285 {
18286 return false;
18287 }
18288
18289 83364 id = id&0xFFF;
18290
18291
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82535 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83364 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18292 464 return false;
18293
18294
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82259 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82900 switch(guysbuf[id].type)
18295 {
18296 // I added a special case for shooters because having traps on the same screen
18297 // was preventing them from spawning due to TMPNORET. This means they will
18298 // never stay dead, though, so it may not be the best solution. - Saf
18299 case eePROJECTILE:
18300 376 return true;
18301
18302
18303 case eeDIG:
18304 {
18305
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18306 {
18307 case 1:
18308
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18309 79 return !getmapflag(scr, mTMPNORET);
18310
18311 47 return true;
18312
18313 75 case 0:
18314 default:
18315 75 return true;
18316 }
18317 }
18318 case eeGANON:
18319 case eeTRAP:
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18321
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18322 [[fallthrough]];
18323 default:
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82259 times.
82259 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18325 82259 break;
18326 }
18327
18328
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 61281 times.
82259 if(!get_qr(qr_NOTMPNORET))
18329 61281 return !getmapflag(scr, mTMPNORET);
18330
18331 20978 return true;
18332 83364 }
18333
18334 1634849 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18335 {
18336
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1346008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1634849 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18337 {
18338 1346008 return;
18339 }
18340
18341 288841 int32_t ctype = rpos_handle.ctype();
18342
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18343
18344 12108 auto [x, y] = rpos_handle.xy();
18345
18346 4036 int32_t cx=-1000, cy=-1000;
18347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18348 {
18349
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18350 {
18351 1508 cx=x+4;
18352 1508 cy=y+7;
18353 1508 }
18354
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18355 {
18356 1315 cx=x-8;
18357 1315 cy=y-1;
18358 1315 }
18359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18360 {
18361 1213 cx=x;
18362 1213 cy=y;
18363 1213 }
18364 4036 }
18365 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18366 {
18367 cx=x;
18368 cy=y;
18369 }
18370
18371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18372 {
18373
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18374 {
18375
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18376 {
18377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18378 4 return; // No point deleting it. A script might be toying with it in some way.
18379 else
18380 guys.del(j);
18381 }
18382 9750 }
18383
18384 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18385 4032 }
18386 1634849 }
18387
18388 34368 static void activate_fireball_statues(mapscr* scr)
18389 {
18390
2/2
✓ Branch 0 taken 32949 times.
✓ Branch 1 taken 1419 times.
34368 if (!(scr->flags11&efFIREBALLS))
18391 {
18392 32949 return;
18393 }
18394
18395 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18396 249744 activate_fireball_statue(rpos_handle);
18397 249744 });
18398 34368 }
18399
18400 35051 void load_default_enemies(mapscr* scr)
18401 {
18402 35051 int screen = scr->screen;
18403 40516 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18404
18405 35051 wallm_load_clk=frame-80;
18406
18407
2/2
✓ Branch 0 taken 33155 times.
✓ Branch 1 taken 1896 times.
35051 if(scr->flags11&efZORA)
18408 {
18409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18410 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18411 1896 }
18412
18413
2/2
✓ Branch 0 taken 34873 times.
✓ Branch 1 taken 178 times.
35051 if(scr->flags11&efTRAP4)
18414 {
18415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18416 {
18417 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18418 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18419 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18420 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18421 178 }
18422 178 }
18423
18424 6204027 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18425 6168976 int32_t ctype = rpos_handle.ctype();
18426 6168976 int32_t cflag = rpos_handle.sflag();
18427 6168976 int32_t cflag_i = rpos_handle.cflag();
18428
18429
4/6
✓ Branch 0 taken 6168976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168630 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168630 times.
6168976 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18430 {
18431 346 auto [x, y] = rpos_handle.xy();
18432
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18433 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18434 346 }
18435
4/6
✓ Branch 0 taken 6168630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168424 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168424 times.
6168630 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18436 {
18437 206 auto [x, y] = rpos_handle.xy();
18438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18439 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18440 206 }
18441
4/6
✓ Branch 0 taken 6168424 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168146 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168146 times.
6168424 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18442 {
18443 278 auto [x, y] = rpos_handle.xy();
18444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18445 {
18446
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18447 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18448 278 }
18449 278 }
18450
4/6
✓ Branch 0 taken 6168146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167747 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167747 times.
6168146 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18451 {
18452 399 auto [x, y] = rpos_handle.xy();
18453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18454 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18455 399 }
18456
4/6
✓ Branch 0 taken 6167747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167314 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167314 times.
6167747 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18457 {
18458 433 auto [x, y] = rpos_handle.xy();
18459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18460 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18461 433 }
18462
18463
1/2
✓ Branch 0 taken 6168976 times.
✗ Branch 1 not taken.
6168976 if(ctype==cSPINTILE1)
18464 {
18465 awaken_spinning_tile(rpos_handle);
18466 }
18467 6168976 });
18468
18469
2/2
✓ Branch 0 taken 34995 times.
✓ Branch 1 taken 56 times.
35051 if(scr->flags11&efTRAP2)
18470 {
18471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18472 {
18473
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18474 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18475
18476
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18477 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18478 56 }
18479 56 }
18480
18481
2/2
✓ Branch 0 taken 34968 times.
✓ Branch 1 taken 83 times.
35051 if(scr->flags11&efROCKS)
18482 {
18483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18484 {
18485 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18486 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18487 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18488 83 }
18489 83 }
18490 35051 }
18491
18492 #define SLOPE_STAGE_COMBOS 0
18493 #define SLOPE_STAGE_FFCS 1
18494 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18495
18496 21196296 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18497 {
18498
2/2
✓ Branch 0 taken 4641751 times.
✓ Branch 1 taken 16554545 times.
21196296 if (stage == SLOPE_STAGE_COMBOS)
18499 16554545 return (region_num_rpos*arg1)+arg2;
18500
2/2
✓ Branch 0 taken 4500555 times.
✓ Branch 1 taken 141196 times.
4641751 if (stage == SLOPE_STAGE_FFCS)
18501 4500555 return (region_num_rpos*7)+arg1;
18502
1/2
✓ Branch 0 taken 141196 times.
✗ Branch 1 not taken.
141196 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18503 141196 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18504 // TODO: what about FFCs from bordering screens?
18505
18506 assert(false);
18507 return 0;
18508 21196296 }
18509
18510 16554545 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18511 {
18512 16554545 mapscr* s = rpos_handle.scr;
18513 16554545 auto& cmb = rpos_handle.combo();
18514
18515 16554545 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18516 16554545 auto it = slopes.find(id);
18517
18518 16554545 bool wasSlope = it!=slopes.end();
18519 16554545 bool isSlope = cmb.type == cSLOPE;
18520
18521
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16554409 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16554545 if(isSlope && !wasSlope)
18522 {
18523 272 auto [x, y] = rpos_handle.xy();
18524 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18525 136 }
18526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16554409 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16554409 else if(wasSlope && !isSlope)
18527 {
18528 slopes.erase(it);
18529 }
18530 16554545 }
18531
18532 141196 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18533 {
18534 141196 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18535 141196 auto it = slopes.find(id);
18536
18537 141196 bool wasSlope = it!=slopes.end();
18538 141196 bool isSlope = is_slope;
18539
18540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 if(isSlope && !wasSlope)
18541 {
18542 static std::vector<word> TMP;
18543 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18544 TMP.resize(num_border_combos * 7 * 4);
18545
18546 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18547 TMP[tmp_index] = cid;
18548 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18549 }
18550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 else if(wasSlope && !isSlope)
18551 {
18552 slopes.erase(it);
18553 }
18554 141196 }
18555
18556 // Load a single column or row from a nearby screen, and load its slopes.
18557 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18558 {
18559 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18560
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18561 171 return;
18562
18563 3713 int offx = 0;
18564 3713 int offy = 0;
18565
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18566 913 offy = -16;
18567
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18568 862 offy = world_h;
18569
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18570 968 offx = -16;
18571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18572 970 offx = world_w;
18573
18574
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18575 {
18576 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18577
2/2
✓ Branch 0 taken 10526 times.
✓ Branch 1 taken 15465 times.
25991 if (!scr) continue;
18578
18579 10526 int slope_count = layer * (16*2);
18580
18581
4/4
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 2700 times.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 5082 times.
10526 if (dir == left || dir == right)
18582 {
18583 5444 int x = dir == left ? 15 : 0;
18584
2/2
✓ Branch 0 taken 59884 times.
✓ Branch 1 taken 5444 times.
65328 for (int y = 0; y < 11; y++)
18585 {
18586 59884 int pos = y * 16 + x;
18587 59884 int cid = scr->data[pos];
18588 59884 bool is_slope = combobuf[cid].type == cSLOPE;
18589
1/2
✓ Branch 0 taken 59884 times.
✗ Branch 1 not taken.
59884 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18590 59884 }
18591 5444 }
18592
3/4
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 2645 times.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
5082 else if (dir == up || dir == down)
18593 {
18594 5082 int y = dir == up ? 10 : 0;
18595
2/2
✓ Branch 0 taken 81312 times.
✓ Branch 1 taken 5082 times.
86394 for (int x = 0; x < 16; x++)
18596 {
18597 81312 int pos = y * 16 + x;
18598 81312 int cid = scr->data[pos];
18599 81312 bool is_slope = combobuf[cid].type == cSLOPE;
18600
1/2
✓ Branch 0 taken 81312 times.
✗ Branch 1 not taken.
81312 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18601 81312 }
18602 5082 }
18603
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15465 times.
✓ Branch 2 taken 10526 times.
25991 }
18604 3884 }
18605
18606 35857 void update_slope_comboposes()
18607 {
18608 15205297 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18609 15169440 update_slope_combopos(rpos_handle);
18610 15169440 });
18611
18612
2/2
✓ Branch 0 taken 34886 times.
✓ Branch 1 taken 971 times.
35857 if (Hero.sideview_mode())
18613 {
18614 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18615
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18616 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18617 971 });
18618 971 }
18619
18620 35857 update_slopes();
18621 35857 }
18622
18623 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18624 1385105 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18625 {
18626 1385105 delete_fireball_shooter(rpos_handle);
18627 1385105 }
18628
18629 //Placeholder in case we need it.
18630 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18631 {
18632 return;
18633 }
18634
18635 // Everything that must be done after we change a screen's combo to another combo. -L
18636 1385105 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18637 {
18638 1385105 rpos_handle.scr->valid |= mVALID;
18639 1385105 activate_fireball_statue(rpos_handle);
18640
18641
2/2
✓ Branch 0 taken 1385011 times.
✓ Branch 1 taken 94 times.
1385105 if(rpos_handle.ctype()==cSPINTILE1)
18642 {
18643 94 awaken_spinning_tile(rpos_handle);
18644 94 }
18645
18646 1385105 update_slope_combopos(rpos_handle);
18647 1385105 }
18648
18649 4500555 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18650 {
18651 4500555 ffcdata* ff = ffc_handle.ffc;
18652 4500555 auto& cmb = ffc_handle.combo();
18653
18654 4500555 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18655 4500555 auto it = slopes.find(id);
18656
18657 4500555 bool wasSlope = it!=slopes.end();
18658
1/2
✓ Branch 0 taken 4500555 times.
✗ Branch 1 not taken.
4500555 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18659
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500555 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500555 if(isSlope && !wasSlope)
18660 {
18661 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18662 }
18663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500555 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500555 else if(wasSlope && !isSlope)
18664 {
18665 slopes.erase(it);
18666 }
18667
18668 4500555 ffc_handle.scr->ffcCountMarkDirty();
18669 4500555 }
18670
18671 4414 void screen_combo_modify_pre(int32_t cid)
18672 {
18673 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18674
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18675 {
18676 5195 screen_combo_modify_preroutine(rpos_handle);
18677 5195 }
18678 2808608 });
18679 4414 }
18680 4414 void screen_combo_modify_post(int32_t cid)
18681 {
18682 4414 combo_caches::refresh(cid);
18683
18684 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18685
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18686 {
18687 5195 screen_combo_modify_postroutine(rpos_handle);
18688 5195 }
18689 2808608 });
18690
18691 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18692
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18693 {
18694 58 screen_ffc_modify_postroutine(ffc_handle);
18695 58 }
18696 139772 });
18697 4414 }
18698
18699 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18700 {
18701 94 int cid = rpos_handle.data();
18702 94 int cset = rpos_handle.cset();
18703 282 auto [x, y] = rpos_handle.xy();
18704
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18705 94 }
18706
18707 // It stands for next_side_pos
18708 // moves sle_x and sle_y to the next position
18709 11464 void nsp(bool random)
18710 {
18711
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18712 {
18713
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18714 {
18715 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18716 1634 sle_y = (zc_oldrand()%10)*16;
18717 1634 }
18718 else
18719 {
18720 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18721 1627 sle_x = (zc_oldrand()%15)*16;
18722 }
18723
18724 3261 return;
18725 }
18726
18727
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18728 {
18729
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18730 1855 sle_y+=16;
18731 else
18732 180 sle_x+=16;
18733 2035 }
18734
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18735 {
18736
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18737 2430 sle_x+=16;
18738 else
18739 166 sle_y-=16;
18740 2596 }
18741
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18742 {
18743
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18744 1404 sle_y-=16;
18745 else
18746 148 sle_x-=16;
18747 1552 }
18748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18749 {
18750
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18751 2020 sle_x-=16;
18752 else
18753 sle_y+=16;
18754 2020 }
18755 11464 }
18756
18757 // moves sle_x and sle_y to the next available position
18758 // returns the direction the enemy should face
18759 2429 int32_t next_side_pos(int32_t screen, bool random)
18760 {
18761 bool blocked;
18762 2429 int32_t c=0;
18763 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18764
18765 2429 do
18766 {
18767
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18768 22928 int x = sle_x + offx;
18769 22928 int y = sle_y + offy;
18770
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18771
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18772
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18773
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18774 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18775
18776
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18777 1 return -1;
18778
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18779 11463 while(blocked);
18780
18781 2428 int32_t dir=0;
18782
18783
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18784
18785
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18786
18787
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18788
18789
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18790
18791 2428 return dir;
18792 2429 }
18793
18794 bool can_side_load(int32_t id)
18795 {
18796 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18797 {
18798 return false;
18799 }
18800
18801 id = id&0xFFF;
18802
18803 switch(guysbuf[id].type)
18804 {
18805 case eeTEK:
18806 case eeLEV:
18807 case eeAQUA:
18808 case eeDONGO:
18809 case eeMANHAN:
18810 case eeGLEEOK:
18811 case eeDIG:
18812 case eeGHOMA:
18813 case eeLANM:
18814 case eePATRA:
18815 case eeGANON:
18816 case eePROJECTILE:
18817 return false;
18818 break;
18819 }
18820
18821 return true;
18822 }
18823
18824 bool enemy_spawning_has_checked_been_here;
18825 static bool enemy_spawning_has_been_here;
18826
18827 35051 static bool check_if_recently_visited()
18828 {
18829
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34529 times.
35051 if (enemy_spawning_has_checked_been_here)
18830 522 return enemy_spawning_has_been_here;
18831
18832 34529 int mi = mapind(cur_map, cur_screen);
18833
18834 34529 enemy_spawning_has_been_here = false;
18835
2/2
✓ Branch 0 taken 207174 times.
✓ Branch 1 taken 34529 times.
241703 for (int i = 0; i < 6; i++)
18836
2/2
✓ Branch 0 taken 197595 times.
✓ Branch 1 taken 9579 times.
216753 if (visited[i] == mi)
18837 9579 enemy_spawning_has_been_here = true;
18838
18839
2/2
✓ Branch 0 taken 9579 times.
✓ Branch 1 taken 24950 times.
34529 if (!enemy_spawning_has_been_here)
18840 {
18841 24950 visited[vhead] = mi; //If not, it adds it to the array,
18842 24950 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18843 24950 }
18844
18845 34529 enemy_spawning_has_checked_been_here = true;
18846 34529 return enemy_spawning_has_been_here;
18847 35051 }
18848
18849 static std::array<bool, MAPSCRS> script_sle;
18850
18851 static int32_t sle_pattern = 0;
18852 static void script_side_load_enemies(mapscr* scr)
18853 {
18854 if (script_sle[scr->screen] || sle_clk) return;
18855
18856 sle_cnt = 0;
18857 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18858 ++sle_cnt;
18859 script_sle[scr->screen] = true;
18860 sle_pattern = scr->pattern;
18861 sle_clk = 0;
18862 }
18863
18864 54516 static void side_load_enemies(mapscr* scr)
18865 {
18866 54516 int screen = scr->screen;
18867
18868
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18869 {
18870 683 sle_pattern = scr->pattern;
18871 683 sle_cnt = 0;
18872 683 int32_t guycnt = 0;
18873
18874 683 int mi = mapind(cur_map, screen);
18875 683 bool reload=true;
18876 683 bool unbeatablereload = true;
18877
18878 683 load_default_enemies(scr);
18879
18880 683 bool beenhere = check_if_recently_visited();
18881
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18882 {
18883 42 sle_cnt=0;
18884 42 reload=false;
18885 42 }
18886
18887
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18888 {
18889 641 sle_cnt = game->guys[mi];
18890
18891
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18892 641 || sle_cnt==0)
18893 {
18894
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18895 1054 ++sle_cnt;
18896 221 }
18897
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18898 {
18899 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18900 {
18901 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18902 {
18903 unbeatablereload = false;
18904 }
18905 }
18906 if (unbeatablereload)
18907 {
18908 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18909 {
18910 ++sle_cnt;
18911 }
18912 }
18913 }
18914 641 }
18915
18916
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18917 {
18918 31 sle_cnt = 0;
18919
18920
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18921 108 ++sle_cnt;
18922 31 }
18923
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18924 sle_cnt = 0;
18925
18926
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18927 2446 ++guycnt;
18928
18929 683 game->guys[mi] = guycnt;
18930 683 }
18931
18932
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18933 {
18934 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18935 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18936
18937
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18938 {
18939 234 return;
18940 }
18941
18942 2195 int32_t enemy_slot=guys.Count();
18943
18944
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18945 sle_cnt--;
18946
18947
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18948 {
18949
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18950 {
18951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18952 {
18953 2195 guys.spr(enemy_slot)->dir = dir;
18954 2195 }
18955
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18956 {
18957 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18958 {
18959 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18960 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18961 }
18962 }
18963 2195 }
18964 2195 }
18965 2195 }
18966
18967
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18968 {
18969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18970 script_sle[screen] = false;
18971 else
18972 {
18973 578 get_screen_state(screen).loaded_enemies = true;
18974 }
18975 578 sle_clk = 0;
18976 578 }
18977 54516 }
18978
18979 1253524 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18980 {
18981
2/2
✓ Branch 0 taken 116388 times.
✓ Branch 1 taken 1137136 times.
1253524 if (!is_in_scrolling_region())
18982
2/4
✓ Branch 0 taken 1137136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137136 times.
1137136 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18983 {
18984 return false; //never 0, never OoB.
18985 }
18986 // No corner enemies
18987
6/6
✓ Branch 0 taken 1082517 times.
✓ Branch 1 taken 171007 times.
✓ Branch 2 taken 41285 times.
✓ Branch 3 taken 1123802 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253524 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
18988 212292 return false;
18989
18990 //Is a no spawn combo...
18991
4/4
✓ Branch 0 taken 1123788 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1123794 times.
1123802 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
18992 20 return false;
18993
18994 // No enemies in dungeon walls
18995
2/2
✓ Branch 0 taken 468705 times.
✓ Branch 1 taken 655089 times.
1123794 if (isdungeon(scr->screen))
18996 {
18997 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
18998
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
18999 319264 return false;
19000 335825 }
19001
19002 // Too close to hero
19003
4/4
✓ Branch 0 taken 77038 times.
✓ Branch 1 taken 727492 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76937 times.
804530 if(tooclose(x,y,40) && t<11)
19004 76937 return false;
19005
19006 // Can't fly onto it?
19007
4/4
✓ Branch 0 taken 139611 times.
✓ Branch 1 taken 587982 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788808 if(isflier(scr->enemy[i])&&
19008
2/2
✓ Branch 0 taken 139221 times.
✓ Branch 1 taken 390 times.
139611 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19009
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78006 times.
139221 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19010 25645 return false;
19011
19012 // Can't jump onto it?
19013 if
19014 (
19015
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790656 guysbuf[scr->enemy[i]].type==eeTEK
19016
19017
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613226 times.
701948 &&
19018 (
19019
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19020
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19021
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19022
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19023 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19024 )
19025 )
19026 {
19027 18 return false;
19028 }
19029
19030 // Other off-limit combos
19031
6/6
✓ Branch 0 taken 587958 times.
✓ Branch 1 taken 113972 times.
✓ Branch 2 taken 499254 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276494 times.
✓ Branch 5 taken 222760 times.
1201184 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
19032
2/2
✓ Branch 0 taken 282052 times.
✓ Branch 1 taken 217202 times.
499254 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19033 499254 guysbuf[scr->enemy[i]].type!=eeZORA)
19034 222760 return false;
19035
19036 // Don't ever generate enemies on these combos!
19037
4/4
✓ Branch 0 taken 478864 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478870 times.
479170 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19038 312 return false;
19039
19040 //BS Dodongos need at least 2 spaces.
19041
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477831 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478870 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19042 {
19043
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19044
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19045
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19046 ((y>144)||_walkflag(x, y+24,2)))
19047 {
19048 return false;
19049 }
19050 19 }
19051
19052 478864 return true;
19053 1147384 }
19054
19055 160640 bool is_ceiling_pattern(int32_t i)
19056 {
19057
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160620 times.
160640 return (i==pCEILING || i==pCEILINGR);
19058 }
19059
19060 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19061 {
19062 5955 std::vector<rpos_t> freeposcache;
19063
19064
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19065 {
19066
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19067 {
19068
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19069 {
19070
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19071 421055 }
19072 1048080 }
19073 65505 }
19074
19075
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19076
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19077
19078 11 return rpos_t::None;
19079 5955 }
19080
19081 81131 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19082 {
19083 81131 int screen = scr->screen;
19084 81131 int x = 0;
19085 81131 int y = 0;
19086 81131 bool placed=false;
19087 81131 int32_t t=-1;
19088
19089 // First: enemy combo flags
19090
2/2
✓ Branch 0 taken 805424 times.
✓ Branch 1 taken 63764 times.
869188 for(int32_t sy=0; sy<176; sy+=16)
19091 {
19092
2/2
✓ Branch 0 taken 12757620 times.
✓ Branch 1 taken 788057 times.
13545677 for(int32_t sx=0; sx<256; sx+=16)
19093 {
19094 12757620 x = offx + sx;
19095 12757620 y = offy + sy;
19096 12757620 int32_t cflag = MAPFLAG(x, y);
19097 12757620 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19098
19099
2/4
✓ Branch 0 taken 12757620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12757620 times.
✗ Branch 3 not taken.
12757620 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19100 {
19101 if(!ok2add(scr, scr->enemy[i]))
19102 {
19103 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19104 }
19105 else
19106 {
19107 addenemy_z(screen,x,
19108 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19109 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19110
19111 ++guycnt;
19112
19113 placed=true;
19114 goto placed_enemy;
19115 }
19116 }
19117
19118
4/4
✓ Branch 0 taken 12740204 times.
✓ Branch 1 taken 17416 times.
✓ Branch 2 taken 12740204 times.
✓ Branch 3 taken 17416 times.
12757620 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19119 {
19120
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17367 times.
17416 if(!ok2add(scr, scr->enemy[i]))
19121 {
19122
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19123 49 }
19124 else
19125 {
19126 34734 addenemy_z(screen,x,
19127
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17367 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19128
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17367 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19129
19130 17367 ++guycnt;
19131
19132 17367 placed=true;
19133 17367 goto placed_enemy;
19134 }
19135 49 }
19136 12740253 }
19137 788057 }
19138
19139 // Next: enemy pattern
19140
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58767 times.
✓ Branch 2 taken 58030 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58030 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58030 times.
63764 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19141 {
19142 58030 do
19143 {
19144
19145 // NES positions
19146 99525 pos%=9;
19147 99525 x=offx+stx[loadside][pos];
19148 99525 y=offy+sty[loadside][pos];
19149 99525 ++pos;
19150 99525 ++t;
19151
2/2
✓ Branch 0 taken 41495 times.
✓ Branch 1 taken 58030 times.
157555 }
19152
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99304 times.
99525 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19153 58030 }
19154
19155
4/4
✓ Branch 0 taken 58030 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57809 times.
63764 if(t<0 || t >= 20) // above enemy pattern failed
19156 {
19157 // Final chance: find a random position anywhere onscreen
19158 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19159
19160
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19161 {
19162 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19163 5944 }
19164 else // All opportunities failed - abort
19165 {
19166 11 return;
19167 }
19168 5944 }
19169
19170 {
19171 63753 int32_t c=0;
19172 63753 c=clk;
19173
19174
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54110 times.
63753 if(!slowguy(scr->enemy[i]))
19175 54110 ++fastguys;
19176
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19177 1586 c=-15*(i-fastguys+2);
19178 else
19179 8057 c=-15*(i+1);
19180
19181
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63753 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19182 {
19183 // Special case for blue leevers
19184
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19185 761 c=-15*(i+1);
19186 else
19187 28399 c=-15;
19188 29160 }
19189
19190
2/2
✓ Branch 0 taken 62953 times.
✓ Branch 1 taken 800 times.
63753 if(!ok2add(scr, scr->enemy[i]))
19191 {
19192
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19193 800 }
19194 else
19195 {
19196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62953 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62953 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19197 {
19198
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125906 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19199
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62953 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19200
19201 62953 ++guycnt;
19202 62953 }
19203 }
19204
19205 63753 placed=true;
19206 63753 } // if(t < 20)
19207
19208 placed_enemy:
19209
19210 // I don't like this, but it seems to work...
19211 static bool foundCarrier;
19212
19213
2/2
✓ Branch 0 taken 59508 times.
✓ Branch 1 taken 21612 times.
81120 if(i==0)
19214 21612 foundCarrier=false;
19215
19216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81120 times.
81120 if(placed)
19217 {
19218
4/4
✓ Branch 0 taken 21612 times.
✓ Branch 1 taken 59508 times.
✓ Branch 2 taken 21443 times.
✓ Branch 3 taken 169 times.
81120 if(i==0 && scr->flags11&efLEADER)
19219 {
19220 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19221
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19222 {
19223 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19225 {
19226 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19227 }
19228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19229 {
19230 162 e->leader = true;
19231 162 }
19232 162 }
19233 169 }
19234
19235 81120 ScreenItemState item_state = get_screen_state(screen).item_state;
19236
5/6
✓ Branch 0 taken 80878 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80878 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80801 times.
81120 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19237 {
19238 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19239
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19240 {
19241 77 e->itemguy = true;
19242 77 foundCarrier=true;
19243 77 }
19244 77 }
19245 81120 }
19246 81131 }
19247
19248 // returns index of first sprite with matching id, -1 if none found
19249 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19250 {
19251 246 int count = guys.Count();
19252
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19253 {
19254 366 enemy* e = (enemy*)guys.spr(i);
19255
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19256 {
19257 239 return e;
19258 }
19259 127 }
19260
19261 7 return nullptr;
19262 246 }
19263
19264 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19265 {
19266 int count = guys.Count();
19267 for(int32_t i=0; i<count; i++)
19268 {
19269 enemy* e = (enemy*)guys.spr(i);
19270 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19271 {
19272 if (n > 1) --n;
19273 else return e;
19274 }
19275 }
19276 return nullptr;
19277 }
19278
19279 bool scriptloadenemies(int screen)
19280 {
19281 // https://discord.com/channels/876899628556091432/1395904851908755577
19282 bool replay_compat_enemies_load_bug = replay_is_active() && replay_get_meta_bool("compat_scriptloadenemies");
19283 auto& state = get_screen_state(screen);
19284 if (!replay_compat_enemies_load_bug)
19285 state.loaded_enemies = true;
19286
19287 if (sle_clk || script_sle[screen]) return false;
19288
19289 mapscr* scr = get_scr(screen);
19290 if(scr->pattern==pNOSPAWN) return false;
19291
19292 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19293 {
19294 script_side_load_enemies(scr);
19295 return true;
19296 }
19297
19298 auto [x, y] = translate_screen_coordinates_to_world(screen);
19299 int32_t pos=zc_oldrand()%9;
19300 int32_t clk=-15,fastguys=0;
19301 int32_t i=0,guycnt=0;
19302 int32_t loadcnt = 10;
19303
19304 for(; i<loadcnt && scr->enemy[i]>0; i++)
19305 {
19306 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19307 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19308 if (guys.Count() > preguycount)
19309 {
19310 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19311 {
19312 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19313 {
19314 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19315 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19316 }
19317 }
19318 }
19319 --clk;
19320 }
19321 return true;
19322 }
19323
19324 14273067 void loadenemies()
19325 {
19326 28926292 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19327 14653225 int screen = scr->screen;
19328 14653225 auto& state = get_screen_state(screen);
19329
2/2
✓ Branch 0 taken 14237995 times.
✓ Branch 1 taken 415230 times.
14653225 if (state.loaded_enemies)
19330 14237995 return;
19331
19332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415230 times.
415230 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19333 return;
19334
19335 // dungeon basements
19336 static byte dngn_enemy_x[4] = {32,96,144,208};
19337
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266266 times.
415230 if (cur_screen>=128)
19338 {
19339
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19341 {
19342 for(int32_t i=0; i<10; i++)
19343 {
19344 if ( scr->enemy[i] )
19345 {
19346 int32_t preguycount = guys.Count();
19347 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19348 if (guys.Count() > preguycount)
19349 {
19350 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19351 {
19352 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19353 {
19354 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19355 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19356 }
19357 }
19358 }
19359 }
19360 }
19361 }
19362 else
19363 {
19364
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19365 {
19366 1900 int32_t preguycount = guys.Count();
19367
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19369 {
19370
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19371 {
19372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19373 {
19374 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19375 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19376 4 }
19377 4 }
19378 1900 }
19379 1900 }
19380 }
19381
19382 475 state.loaded_enemies = true;
19383 475 return;
19384 }
19385
19386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266266 times.
266266 if (scr->pattern == pNOSPAWN)
19387 return;
19388
19389 // TODO: configure when screen enemies spawn.
19390
2/2
✓ Branch 0 taken 88974 times.
✓ Branch 1 taken 177292 times.
266266 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19391 177292 return;
19392
19393
4/4
✓ Branch 0 taken 50527 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34458 times.
88974 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19394 {
19395 54516 side_load_enemies(scr);
19396 54516 return;
19397 }
19398
19399 34458 state.loaded_enemies = true;
19400
19401 // check if it's the dungeon boss and it has been beaten before
19402
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34099 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34458 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&(1 << li_boss_killed))
19403 90 return;
19404
19405 34368 int32_t loadcnt = 10;
19406 34368 int16_t mi = mapind(cur_map, screen);
19407 34368 bool beenhere = check_if_recently_visited();
19408
19409 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19410 34368 bool reload = true;
19411
4/4
✓ Branch 0 taken 9722 times.
✓ Branch 1 taken 24646 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5014 times.
34368 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19412 {
19413 5014 loadcnt = 0; //It will tell it not to load any enemies,
19414 5014 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19415 5014 }
19416
19417 34368 bool unbeatablereload = true;
19418
2/2
✓ Branch 0 taken 5014 times.
✓ Branch 1 taken 29354 times.
34368 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19419 {
19420 29354 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19421
19422
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19065 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29354 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19424 19065 loadcnt = 10; //That means all enemies need to be respawned.
19425
3/4
✓ Branch 0 taken 24646 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24646 times.
✗ Branch 3 not taken.
29354 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19426 {
19427 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19428 {
19429 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19430 {
19431 unbeatablereload = false;
19432 }
19433 }
19434 if (unbeatablereload)
19435 {
19436 loadcnt = 10;
19437 }
19438 }
19439 29354 }
19440
19441
4/4
✓ Branch 0 taken 32907 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32714 times.
34368 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19442 1654 loadcnt = 10; //All enemies also need to be respawned.
19443
19444 // do enemies that are always loaded
19445 34368 load_default_enemies(scr);
19446 34368 activate_fireball_statues(scr);
19447
19448 34368 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19449 34368 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19450 34368 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19451
4/4
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 100343 times.
✓ Branch 2 taken 81131 times.
✓ Branch 3 taken 34368 times.
115499 for(; i<loadcnt && scr->enemy[i]>0; i++)
19452 {
19453 81131 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19454 81131 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19455
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80320 times.
81131 if (guys.Count() > preguycount)
19456 {
19457
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 2352 times.
80320 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19458 {
19459
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2348 times.
2352 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19460 {
19461 2348 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19462 2348 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19463 2348 }
19464 2352 }
19465 80320 }
19466
19467 81131 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19468 81131 }
19469
19470 34368 game->guys[mi] = guycnt;
19471 14653225 });
19472 14273067 }
19473
19474 233 void moneysign()
19475 {
19476 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19477 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19478 233 set_clip_state(pricesdisplaybuf, 0);
19479 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19480 233 }
19481
19482 3303 void putprices(bool sign)
19483 {
19484
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3271 times.
3303 if(fadeclk > 0) return;
19485
19486 3271 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19487 3271 int32_t step=32;
19488 3271 int32_t x=80;
19489
19490
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2990 times.
3271 if(prices[2]==0)
19491 {
19492 2990 step<<=1;
19493
19494
2/2
✓ Branch 0 taken 2958 times.
✓ Branch 1 taken 32 times.
2990 if(prices[1]==0)
19495 {
19496 2958 x=112;
19497 2958 }
19498 2990 }
19499
19500
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 9813 times.
13084 for(int32_t i=0; i<3; i++)
19501 {
19502 // Kind of stupid, but it works: 100000 is used to indicate that an item
19503 // has a price of zero rather than there being no item.
19504 // 100000 isn't a valid price, so this doesn't cause problems.
19505
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8774 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9813 if(prices[i]!=0 && prices[i]<100000)
19506 {
19507 char buf[8];
19508 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19509
19510 1039 int32_t l=(int32_t)strlen(buf);
19511 1039 set_clip_state(pricesdisplaybuf, 0);
19512
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19513 1039 }
19514
19515 9813 x+=step;
19516 9813 }
19517 3303 }
19518
19519 // Setting up special rooms
19520 // Also called when the Letter is used successfully.
19521 1210 void setupscreen()
19522 {
19523 1210 boughtsomething=false;
19524
19525 // Either the origin screen, or if in a 0x80 room the screen player came from.
19526
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19527 1210 mapscr* scr = origin_scr;
19528
19529 1210 word str=base_scr->str;
19530
19531 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19532
19533 // Prices are already set to 0 in dowarp()
19534
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19535 {
19536 case rSP_ITEM: // special item
19537 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19538 164 break;
19539
19540 case rINFO: // pay for info
19541 {
19542 28 int32_t count = 0;
19543 28 int32_t base = 88;
19544 28 int32_t step = 5;
19545
19546 28 moneysign();
19547
19548
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19549 {
19550
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19551 {
19552 84 ++count;
19553 84 }
19554 else
19555 break;
19556 84 }
19557
19558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19559 {
19560
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19561 {
19562 base = 88+32;
19563 }
19564
19565
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19566 {
19567 step = 6;
19568 }
19569
19570
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19571 {
19572 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19573 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19574 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19575
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19576 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19577 84 int32_t itemid = current_item_id(itype_wealthmedal);
19578
19579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19580 {
19581 if(itemsbuf[itemid].flags & item_flag1)
19582 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19583 else
19584 prices[i]-=itemsbuf[itemid].misc1;
19585 prices[i]=vbound(prices[i], -99999, 0);
19586 if(prices[i]==0)
19587 prices[i]=100000;
19588 }
19589
19590
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19591 prices[i]=-1;
19592 84 }
19593 28 }
19594
19595 28 break;
19596 }
19597
19598 case rMONEY: // secret money
19599 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19600 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19601 44 break;
19602
19603 case rGAMBLE: // gambling
19604 11 prices[0]=prices[1]=prices[2]=-10;
19605 11 moneysign();
19606 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19607 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19608 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19609 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19610 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19611 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19612 11 break;
19613
19614 case rREPAIR: // door repair
19615
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19616 // }
19617 13 repaircharge=base_scr->catchall;
19618 13 break;
19619
19620 case rMUPGRADE: // upgrade magic
19621 2 adjustmagic=true;
19622 2 break;
19623
19624 case rLEARNSLASH: // learn slash attack
19625 2 learnslash=true;
19626 2 break;
19627
19628 case rRP_HC: // heart container or red potion
19629 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19630 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19631 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19632 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19633 17 break;
19634
19635 case rP_SHOP: // potion shop
19636
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19637 {
19638 12 str=0;
19639 12 break;
19640 }
19641
19642 [[fallthrough]];
19643 case rTAKEONE: // take one
19644 case rSHOP: // shop
19645 {
19646 194 int32_t count = 0;
19647 194 int32_t base = 88;
19648 194 int32_t step = 5;
19649
19650
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19651 193 moneysign();
19652
19653 //count and align the stuff
19654
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19655 {
19656
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19657 {
19658 523 ++count;
19659 523 }
19660 else
19661 {
19662 37 break;
19663 }
19664 523 }
19665
19666
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19667 {
19668 22 base = 88+32;
19669 22 }
19670
19671
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19672 {
19673 15 step = 6;
19674 15 }
19675
19676
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19677 {
19678 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19679 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19680
19681
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19682 {
19683 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19684
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19685 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19686 521 int32_t itemid = current_item_id(itype_wealthmedal);
19687
19688
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19689 {
19690
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19691 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19692 else
19693 prices[i]+=itemsbuf[itemid].misc1;
19694 9 prices[i]=vbound(prices[i], 0, 99999);
19695
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19696 prices[i]=100000;
19697 9 }
19698
19699
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19700 prices[i]=1;
19701 521 }
19702 523 }
19703
19704 194 break;
19705 }
19706 case rBOTTLESHOP: // bottle shop
19707 {
19708 1 int32_t count = 0;
19709 1 int32_t base = 88;
19710 1 int32_t step = 5;
19711
19712 1 moneysign();
19713 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19714 //count and align the stuff
19715
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19716 {
19717
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19718 {
19719 3 ++count;
19720 3 }
19721 else
19722 {
19723 break;
19724 }
19725 3 }
19726
19727
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19728 {
19729 base = 88+32;
19730 }
19731
19732
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19733 {
19734 step = 6;
19735 }
19736
19737
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19738 {
19739 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19740 //{ Setup dummy item
19741 3 item* curItem = ((item*)items.spr(items.Count()-1));
19742 3 curItem->PriceIndex = i;
19743 3 newcombo const& cmb = combobuf[bst.comb[i]];
19744
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19745 {
19746 curItem->yofs = -32768;
19747 }
19748 3 curItem->o_tile = cmb.o_tile;
19749 3 curItem->o_cset = bst.cset[i];
19750 3 curItem->cs = curItem->o_cset;
19751 3 curItem->tile = cmb.o_tile;
19752 3 curItem->o_speed = cmb.speed;
19753 3 curItem->o_delay = 0;
19754 3 curItem->frames = cmb.frames;
19755 3 curItem->flip = cmb.flip;
19756 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19757 3 curItem->pstring = 0;
19758 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19759 3 curItem->flash = false;
19760 3 curItem->twohand = false;
19761 3 curItem->anim = true;
19762 3 curItem->hit_width=1;
19763 3 curItem->hyofs=4;
19764 3 curItem->hit_height=12;
19765 3 curItem->script=0;
19766 3 curItem->txsz=1;
19767 3 curItem->tysz=1;
19768 //}
19769
19770 3 prices[i] = bst.price[i];
19771
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19772 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19773 3 int32_t itemid = current_item_id(itype_wealthmedal);
19774
19775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19776 {
19777 if(itemsbuf[itemid].flags & item_flag1)
19778 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19779 else
19780 prices[i]+=itemsbuf[itemid].misc1;
19781 prices[i]=vbound(prices[i], 0, 99999);
19782 if(prices[i]==0)
19783 prices[i]=100000;
19784 }
19785
19786
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19787 prices[i]=1;
19788 3 }
19789
19790 1 break;
19791 }
19792
19793 case rBOMBS: // more bombs
19794 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19795 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19796 19 prices[0]=-base_scr->catchall;
19797 19 break;
19798
19799 case rARROWS: // more arrows
19800 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19801 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19802 prices[0]=-base_scr->catchall;
19803 break;
19804
19805 case rSWINDLE: // leave heart container or money
19806 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19807 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19808 14 prices[0]=-1;
19809 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19810 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19811 14 prices[1]=-base_scr->catchall;
19812 14 break;
19813
19814 }
19815
19816
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19817 {
19818 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19819 19 int32_t itemid = current_item_id(itype_wealthmedal);
19820
19821
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19822 {
19823 if(itemsbuf[itemid].flags & item_flag1)
19824 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19825 else
19826 prices[i]+=itemsbuf[itemid].misc1;
19827 }
19828
19829
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19830 prices[i]=-1;
19831 19 }
19832
19833 1210 putprices(false);
19834
19835
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19836 {
19837 1151 donewmsg(base_scr, str);
19838 1151 }
19839 else
19840 {
19841 59 Hero.unfreeze();
19842 }
19843 1210 }
19844
19845 enum
19846 {
19847 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19848 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19849
19850 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19851
19852 MNU_DATA_MAX
19853 };
19854 struct menu_choice
19855 {
19856 int32_t x, y;
19857 int32_t pos;
19858 int32_t upos, dpos, lpos, rpos;
19859 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19860 18 {}
19861 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19862 int32_t dpos, int32_t lpos, int32_t rpos)
19863 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19864 18 {}
19865 };
19866 static int32_t msg_menu_data[MNU_DATA_MAX];
19867 static bool do_run_menu = false;
19868 bool do_end_str = false;
19869 static bool wait_advance = false;
19870 418 static std::map<int32_t, menu_choice> menu_options;
19871 43874 void clr_msg_data()
19872 {
19873 43874 do_end_str = false;
19874 43874 wait_advance = false;
19875 43874 do_run_menu = false;
19876 43874 menu_options.clear();
19877 43874 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19878 43874 }
19879
19880 static char namebuf[9] = {0};
19881 static char* nameptr = NULL;
19882 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19883 2036 bool runMenuCursor()
19884 {
19885 2036 clear_bitmap(msg_menu_bmp_buf);
19886
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19887 {
19888 msg_menu_data[MNU_CHOSEN] = 0;
19889 return true; //end menu
19890 }
19891 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19892 //If the cursor is at an invalid pos, find the first pos >= 0...
19893
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19894 {
19895 pos = 0;
19896 while(menu_options.find(pos) == menu_options.end())
19897 ++pos;
19898 }
19899 2036 menu_choice* ch = &menu_options[pos];
19900
19901 2036 bool pressed = true;
19902
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19903
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19904
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19905
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19906 2010 else pressed = false;
19907
19908
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19909 26 msg_menu_data[MNU_TIMER] = 1;
19910
19911 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19912 2036 bool held = false;
19913
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19914 {
19915 90 held = true;
19916
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19920 89 else held = false;
19921 90 }
19922 //If the cursor is at an invalid pos, find the first pos >= 0...
19923
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19924 {
19925 pos = 0;
19926 while(menu_options.find(pos) == menu_options.end())
19927 ++pos;
19928 }
19929
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19930 27 sfx(MsgStrings[msgstr].sfx);
19931
19932 2036 ch = &menu_options[pos];
19933 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19934 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19935 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19936 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19937
19938 2036 msg_menu_data[MNU_CHOSEN] = pos;
19939
19940
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19941 {
19942 603 rAbtn(); //Eat
19943
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19944 603 }
19945
19946
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19947 //Eat inputs
19948 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19949
19950
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19951 5 menu_options.clear();
19952
19953 2036 return ret;
19954 //false if pos changed this frame; no confirming while moving the cursor!
19955 2036 }
19956
19957 839994 bool bottom_margin_clip()
19958 {
19959 891831 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19960
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 51837 times.
839994 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19961 }
19962
19963 void update_msgstr();
19964
19965 3293 static bool parsemsgcode(const StringCommand& command)
19966 {
19967 3293 auto& args = command.args;
19968 3293 int last_arg = 0;
19969
19970
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19971 {
19972 case MSGC_NEWLINE:
19973 {
19974 1280 ssc_tile_hei = ssc_tile_hei_buf;
19975
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19976 1280 ssc_tile_hei_buf = -1;
19977 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19978 1280 cursor_x=msg_margins[left];
19979 1280 return true;
19980 }
19981
19982 case MSGC_COLOUR:
19983 {
19984 1644 int32_t cset = args[0];
19985 1644 msgcolour = CSET(cset)+(args[1]);
19986 1644 return true;
19987 }
19988
19989 case MSGC_SHDCOLOR:
19990 {
19991 int32_t cset = args[0];
19992 msg_shdcol = CSET(cset)+args[1];
19993 return true;
19994 }
19995 case MSGC_SHDTYPE:
19996 {
19997 msg_shdtype = args[0];
19998 return true;
19999 }
20000
20001 case MSGC_SPEED:
20002 {
20003 56 msgspeed=args[0];
20004 56 return true;
20005 }
20006
20007 case MSGC_CTRUP:
20008 {
20009 int32_t a1 = args[0];
20010 int32_t a2 = args[1];
20011 game->change_counter(a2, a1);
20012 return true;
20013 }
20014
20015 case MSGC_CTRDN:
20016 {
20017 5 int32_t a1 = args[0];
20018 5 int32_t a2 = args[1];
20019 5 game->change_counter(-a2, a1);
20020 5 return true;
20021 }
20022
20023 case MSGC_CTRSET:
20024 {
20025 7 int32_t a1 = args[0];
20026 7 int32_t a2 = args[1];
20027 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20028 7 return true;
20029 }
20030
20031 case MSGC_CTRUPPC:
20032 case MSGC_CTRDNPC:
20033 case MSGC_CTRSETPC:
20034 {
20035 2 int32_t counter = args[0];
20036 2 int32_t amount = args[1];
20037 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20038
20039
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20040 amount*=-1;
20041
20042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20043 game->set_counter(amount, counter);
20044 else
20045 2 game->change_counter(amount, counter);
20046
20047 2 return true;
20048 }
20049
20050 case MSGC_GIVEITEM:
20051 {
20052 70 int32_t itemID = args[0];
20053
20054 70 getitem(itemID, true);
20055
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20056 {
20057 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20058 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20059 70 }
20060 70 return true;
20061 }
20062
20063
20064 case MSGC_WARP:
20065 {
20066 int32_t dmap = args[0];
20067 int32_t scrn = args[1];
20068 int32_t dx = args[2];
20069 int32_t dy = args[3];
20070 int32_t wfx = args[4];
20071 int32_t sfx = args[5];
20072 if(dx >= MAX_SCC_ARG) dx = -1;
20073 if(dy >= MAX_SCC_ARG) dy = -1;
20074 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20075 do_end_str = true;
20076 return true;
20077 }
20078
20079 case MSGC_SETSCREEND:
20080 {
20081 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20082 int32_t screen = args[1];
20083 int32_t reg = args[2];
20084 int32_t val = args[3];
20085 FFCore.set_screen_d(screen + dmap, reg, val);
20086 return true;
20087 }
20088 case MSGC_TAKEITEM:
20089 {
20090 11 int32_t itemID = args[0];
20091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20092 {
20093 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20094 }
20095 11 takeitem(itemID);
20096
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20097 {
20098 game->forced_bwpn = -1;
20099 } //not else if! -Z
20100
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20101 {
20102 game->forced_awpn = -1;
20103 }
20104
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20105 {
20106 game->forced_xwpn = -1;
20107 } //not else if! -Z
20108
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20109 {
20110 game->forced_ywpn = -1;
20111 }
20112 11 verifyBothWeapons();
20113 11 return true;
20114 }
20115
20116 case MSGC_SFX:
20117 {
20118 22 sfx(args[0]);
20119 22 return true;
20120 }
20121
20122 case MSGC_MIDI:
20123 {
20124 7 int32_t music = args[0];
20125
20126
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20127 1 music_stop();
20128 else
20129 6 jukebox(music+(ZC_MIDI_COUNT-1));
20130
20131 7 return true;
20132 }
20133
20134 case MSGC_FONT:
20135 {
20136 int fontid = args[0];
20137 int oh = text_height(msgfont);
20138 msgfont = get_zc_font(fontid);
20139 int nh = text_height(msgfont);
20140 int mh = std::max(oh,nh);
20141 if(mh > ssc_tile_hei_buf)
20142 ssc_tile_hei_buf = mh;
20143 return true;
20144 }
20145 case MSGC_RUN_FRZ_GENSCR:
20146 {
20147 word scr_id = args[0];
20148 bool force_redraw = args[1]!=0;
20149 if(force_redraw)
20150 {
20151 update_msgstr();
20152 draw_screen();
20153 }
20154 FFCore.runGenericFrozenEngine(scr_id);
20155 return true;
20156 }
20157 case MSGC_DRAWTILE:
20158 {
20159 int32_t tl = args[0];
20160 int32_t cs = args[1];
20161 int32_t t_wid = args[2];
20162 int32_t t_hei = args[3];
20163 int32_t fl = args[4];
20164
20165 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20166 {
20167 ssc_tile_hei = ssc_tile_hei_buf;
20168 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20169 ssc_tile_hei_buf = -1;
20170 cursor_y += thei + MsgStrings[msgstr].vspace;
20171 if(bottom_margin_clip()) return true;
20172 cursor_x=msg_margins[left];
20173 }
20174
20175 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20176 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20177 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20178 return true;
20179 }
20180
20181 case MSGC_GOTOIFRAND:
20182 {
20183 1 int32_t odds = args[0];
20184
20185 1 last_arg = 1;
20186
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20187 1 goto switched;
20188
20189 return true;
20190 }
20191
20192 case MSGC_GOTOIFGLOBAL:
20193 {
20194 int32_t arg = args[0];
20195 int32_t d = zc_min(7,arg);
20196 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20197 arg = args[1];
20198
20199 if(game->screen_d[s][d] >= arg)
20200 {
20201 last_arg = 2;
20202 goto switched;
20203 }
20204
20205 return true;
20206 }
20207
20208 case MSGC_CHANGEPORTRAIT:
20209 {
20210 return true; //not implemented
20211 }
20212
20213 case MSGC_GOTOIFCREEND:
20214 {
20215 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20216 int32_t screen = args[1];
20217 int32_t reg = args[2];
20218 int32_t val = args[3];
20219 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20220 {
20221 last_arg = 4;
20222 goto switched;
20223 }
20224 return true;
20225 }
20226
20227 case MSGC_GOTOIF:
20228 {
20229 122 int32_t it = args[0];
20230
20231
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20232 {
20233 35 last_arg = 1;
20234 35 goto switched;
20235 }
20236
20237 87 return true;
20238 }
20239
20240 case MSGC_GOTOIFCTR:
20241 {
20242
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20243 {
20244 14 last_arg = 2;
20245 14 goto switched;
20246 }
20247
20248 14 return true;
20249 }
20250
20251 case MSGC_GOTOIFCTRPC:
20252 {
20253 int32_t counter = args[0];
20254 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20255
20256 if(game->get_counter(counter)>=amount)
20257 {
20258 last_arg = 2;
20259 goto switched;
20260 }
20261
20262 return true;
20263 }
20264
20265 case MSGC_GOTOIFTRICOUNT:
20266 {
20267 if(TriforceCount() >= args[0])
20268 {
20269 last_arg = 1;
20270 goto switched;
20271 }
20272
20273 return true;
20274 }
20275
20276 case MSGC_GOTOIFTRI:
20277 {
20278 int32_t lev = args[0];
20279
20280 if(lev<MAXLEVELS && game->lvlitems[lev]&(1 << li_mcguffin))
20281 {
20282 last_arg = 1;
20283 goto switched;
20284 }
20285
20286 return true;
20287 }
20288
20289 case MSGC_SETUPMENU:
20290 {
20291 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20292 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20293 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20294 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20295 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20296 5 return true;
20297 }
20298
20299 case MSGC_MENUCHOICE:
20300 {
20301 18 int32_t pos = args[0];
20302 18 int32_t upos = args[1];
20303 18 int32_t dpos = args[2];
20304 18 int32_t lpos = args[3];
20305 18 int32_t rpos = args[4];
20306
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20307 {
20308 2 ssc_tile_hei = ssc_tile_hei_buf;
20309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20310 2 ssc_tile_hei_buf = -1;
20311 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20313 2 cursor_x=msg_margins[left];
20314 2 }
20315
20316 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20317 18 upos, dpos, lpos, rpos);
20318
20319
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20320 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20321 18 return true;
20322 }
20323
20324 case MSGC_RUNMENU:
20325 {
20326 5 msg_menu_data[MNU_CHOSEN] = 0;
20327 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20329 return true;
20330 5 do_run_menu = true;
20331 5 return true;
20332 }
20333
20334 case MSGC_GOTOMENUCHOICE:
20335 {
20336 7 int32_t choice = args[0];
20337
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20338 {
20339 5 last_arg = 1;
20340 5 goto switched;
20341 }
20342
20343 2 return true;
20344 }
20345
20346 case MSGC_ENDSTRING:
20347 {
20348 3 do_end_str = true;
20349 3 return true;
20350 }
20351 case MSGC_WAIT_ADVANCE:
20352 {
20353 wait_advance = true;
20354 linkedmsgclk = 51;
20355 return true;
20356 }
20357 case MSGC_TRIGSECRETS:
20358 {
20359 bool perm = args[0];
20360 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20361 if(perm)
20362 setmapflag(msgscr, mSECRET);
20363 return true;
20364 }
20365 case MSGC_TRIG_CMB_COPYCAT:
20366 {
20367 int copy_id = args[0];
20368 if(copy_id == byte(copy_id))
20369 trig_copycat(copy_id);
20370 return true;
20371 }
20372 case MSGC_SETSCREENSTATE:
20373 {
20374 int32_t flag = args[0];
20375 if(unsigned(flag)>=mMAXIND)
20376 {
20377 Z_error("SCC 133: Flag %d is invalid\n", flag);
20378 return true;
20379 }
20380 bool state = args[1];
20381 if(state)
20382 setmapflag(msgscr, 1<<flag);
20383 else
20384 unsetmapflag(msgscr, 1<<flag, true);
20385 return true;
20386 }
20387 case MSGC_SETSCREENSTATER:
20388 {
20389 int32_t map = args[0];
20390 int32_t scrid = args[1];
20391 if(map < 1 || map > map_count)
20392 {
20393 Z_error("SCC 134: Map %d is invalid\n", map);
20394 return true;
20395 }
20396 if(unsigned(scrid)>=0x80)
20397 {
20398 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20399 return true;
20400 }
20401
20402 int32_t flag = args[2];
20403 if(unsigned(flag)>=mMAXIND)
20404 {
20405 Z_error("SCC 134: Flag %d is invalid\n", flag);
20406 return true;
20407 }
20408 bool state = args[3];
20409 if(state)
20410 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20411 else
20412 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20413 return true;
20414 }
20415 switched:
20416 55 int32_t lev = args[last_arg];
20417
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20418
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20419 {
20420 setmsg(lev);
20421 }
20422 else
20423 {
20424 55 donewmsg(msgscr, lev);
20425 55 ssc_tile_hei_buf = -1;
20426 }
20427 55 putprices(false);
20428 55 return true;
20429 }
20430
20431 return false;
20432 3293 }
20433
20434 3299 static std::string parsemsgcode2(const StringCommand& command)
20435 {
20436
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20437 {
20438
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20439 }
20440 else
20441 {
20442 3293 parsemsgcode(command);
20443 }
20444
20445
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20446 3299 }
20447
20448 252704 static bool putmsgchar(bool play_sfx)
20449 {
20450 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20451 DCHECK(!msg_it->character.empty());
20452
20453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252704 times.
252704 if (bottom_margin_clip())
20454 return false;
20455
20456 // If the current word would overflow the margins, increment cursor to the next line.
20457 252704 const char* rem_word = msg_it->remaining_word();
20458 252704 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20459
4/4
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 247033 times.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 5081 times.
258283 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20460
4/4
✓ Branch 0 taken 5579 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5671 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20461 {
20462 5579 ssc_tile_hei = ssc_tile_hei_buf;
20463
1/2
✓ Branch 0 taken 5579 times.
✗ Branch 1 not taken.
5579 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20464 5579 ssc_tile_hei_buf = -1;
20465 5579 cursor_y += thei + MsgStrings[msgstr].vspace;
20466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5579 times.
5579 if (bottom_margin_clip()) return false;
20467
20468 5579 cursor_x = msg_margins[left];
20469 5579 }
20470
20471
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217745 times.
252704 if (play_sfx)
20472 217745 sfx(MsgStrings[msgstr].sfx);
20473
20474 // Print the character (unless it's just a space).
20475
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20476 193700 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20477
20478 // Move the cursor.
20479 252704 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20480
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20481 193700 cursor_x += MsgStrings[msgstr].hspace;
20482
20483 252704 return true;
20484 252704 }
20485
20486 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20487
20488 static void msg_tick_end(bool disappear = false);
20489 241762 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20490 {
20491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241762 times.
241762 if (msg_it->done())
20492 return msg_tick_exit;
20493
20494
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239731 times.
241762 if (!do_run_menu)
20495 {
20496
4/4
✓ Branch 0 taken 239731 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 239731 times.
✓ Branch 3 taken 3299 times.
243030 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20497 {
20498 3299 bool one_frame_command_delay = !replay_version_check(41);
20499 3299 std::string text = parsemsgcode2(msg_it->command);
20500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3299 times.
3299 if (wait_advance)
20501 break;
20502
20503
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20504 {
20505
2/4
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3293 times.
✗ Branch 3 not taken.
3293 msg_it->set_buffer("");
20506 // Advance the iterator to run many commands in one frame.
20507
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20508
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20509 3293 }
20510 else
20511 {
20512
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20513
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20515 6 msg_it->post_segment_delay = 1;
20516 }
20517
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3299 times.
3299 }
20518
20519
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236554 times.
239731 if (msg_it->state == MsgStr::iterator::CHARACTER)
20520 {
20521
1/2
✓ Branch 0 taken 236554 times.
✗ Branch 1 not taken.
236554 if (!putmsgchar(play_sfx)) return msg_tick_break;
20522 236554 }
20523 239731 }
20524
20525 241762 bool wait_advance_check_early = !burst_mode;
20526
20527
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163273 times.
241762 if (wait_advance_check_early)
20528 {
20529
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163272 times.
163273 if (do_end_str)
20530 {
20531 1 msg_tick_end();
20532 1 return msg_tick_exit;
20533 }
20534
20535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163272 times.
163272 if (wait_advance)
20536 {
20537 msg_it->next();
20538 return msg_tick_exit;
20539 }
20540 163272 }
20541
20542
2/2
✓ Branch 0 taken 239725 times.
✓ Branch 1 taken 2036 times.
241761 if (do_run_menu)
20543 {
20544
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20545 {
20546 5 do_run_menu = false;
20547
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20548 {
20549 2 msg_it->next();
20550 2 return msg_tick(play_sfx, burst_mode);
20551 }
20552 3 }
20553 2031 else return msg_tick_break;
20554 3 }
20555
20556 239728 msg_it->next();
20557
20558
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 77955 times.
239728 if (!wait_advance_check_early)
20559 {
20560
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20561 {
20562 2 msg_tick_end();
20563 2 return msg_tick_exit;
20564 }
20565
20566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20567 return msg_tick_exit;
20568 77953 }
20569
20570
4/4
✓ Branch 0 taken 4007 times.
✓ Branch 1 taken 235719 times.
✓ Branch 2 taken 2017 times.
✓ Branch 3 taken 1990 times.
239726 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20571 {
20572
1/2
✓ Branch 0 taken 2017 times.
✗ Branch 1 not taken.
2017 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20573 setmsg(MsgStrings[msgstr].nextstring);
20574 2017 }
20575
20576 239726 return msg_tick_continue;
20577 241762 }
20578
20579 165560 static void msg_tick_end(bool disappear)
20580 {
20581
2/2
✓ Branch 0 taken 164547 times.
✓ Branch 1 taken 1013 times.
165560 if (disappear)
20582 1013 goto disappear;
20583
20584 // Done printing the string
20585
8/8
✓ Branch 0 taken 164544 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 163047 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 159021 times.
✓ Branch 5 taken 4026 times.
✓ Branch 6 taken 159021 times.
✓ Branch 7 taken 4026 times.
164547 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20586 {
20587
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4026 times.
4029 if(!do_end_str)
20588 {
20589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026 times.
4026 while (msg_it->state == MsgStr::iterator::COMMAND)
20590 {
20591 parsemsgcode2(msg_it->command);
20592 msg_it->next();
20593 }
20594 4026 }
20595
20596 // Go to next string, or make it disappear by going to string 0.
20597
5/6
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4029 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20598 {
20599 3033 linkedmsgclk=do_end_str?1:51;
20600 3033 }
20601
20602
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
4029 if(MsgStrings[msgstr].nextstring==0)
20603 {
20604
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 996 times.
2010 if(!get_qr(qr_MSGDISAPPEAR))
20605 996 {
20606 disappear:
20607 2009 msg_active = false;
20608 2009 Hero.finishedmsg();
20609 2009 }
20610
20611
2/2
✓ Branch 0 taken 3010 times.
✓ Branch 1 taken 13 times.
3023 if(repaircharge)
20612 {
20613
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20614 13 repaircharge = 0;
20615 13 }
20616
20617
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(adjustmagic)
20618 {
20619
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20620 {
20621
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20622 2 game->set_magicdrainrate(1);
20623 2 }
20624 else if(game->get_magicdrainrate() > 1)
20625 {
20626 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20627 }
20628 2 adjustmagic = false;
20629 2 sfx(WAV_SCALE);
20630
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20631 2 }
20632
20633
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(learnslash)
20634 {
20635 2 game->set_canslash(1);
20636 2 learnslash = false;
20637 2 sfx(WAV_SCALE);
20638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20639 2 }
20640 3023 }
20641 5042 }
20642 165560 }
20643
20644 6228 static void msg_consume_spaces()
20645 {
20646
2/2
✓ Branch 0 taken 6228 times.
✓ Branch 1 taken 16150 times.
22378 while (msg_it->character == " ")
20647 {
20648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20649
20650 // Advance the iterator.
20651 16150 msg_it->next();
20652
20653 // The "Continue From Previous" feature
20654
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20655 {
20656 if(MsgStrings[msgstr].nextstring)
20657 {
20658 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20659 {
20660 setmsg(MsgStrings[msgstr].nextstring);
20661 }
20662 }
20663 }
20664 }
20665 6228 }
20666
20667 14624575 void putmsg()
20668 {
20669
2/2
✓ Branch 0 taken 682601 times.
✓ Branch 1 taken 13941974 times.
14624575 if(!msgorig) msgorig=msgstr;
20670
20671
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14624575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14624575 if(wait_advance && linkedmsgclk < 1)
20672 linkedmsgclk = 1;
20673
2/2
✓ Branch 0 taken 14346395 times.
✓ Branch 1 taken 278180 times.
14624575 if(linkedmsgclk>0)
20674 {
20675
2/2
✓ Branch 0 taken 126729 times.
✓ Branch 1 taken 151451 times.
278180 if(linkedmsgclk==1)
20676 {
20677
6/6
✓ Branch 0 taken 126726 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123816 times.
✓ Branch 3 taken 2910 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123698 times.
126729 if(do_end_str||cAbtn()||cBbtn())
20678 {
20679 3031 do_end_str = false;
20680 3031 linkedmsgclk = 0;
20681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if(wait_advance)
20682 {
20683 wait_advance = false;
20684 }
20685 else
20686 {
20687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if (!msgscr) msgscr = hero_scr;
20688 3031 msgstr=MsgStrings[msgstr].nextstring;
20689 3031 ssc_tile_hei_buf = -1;
20690
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3031 if(!msgstr && enqueued_str)
20691 {
20692 msgstr = enqueued_str;
20693 enqueued_str = 0;
20694 }
20695
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
3031 if(!msgstr)
20696 {
20697 1013 msgfont=get_zc_font(font_zfont);
20698
20699
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20700 1009 blockpath=false;
20701
20702 1013 dismissmsg();
20703 1013 msg_tick_end(true);
20704 1013 return;
20705 }
20706
20707 2018 donewmsg(msgscr, msgstr);
20708 2018 putprices(false);
20709 }
20710 2018 }
20711 125716 }
20712 else
20713 {
20714 151451 --linkedmsgclk;
20715 }
20716 277167 }
20717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14623562 times.
14623562 if(wait_advance) return; //Waiting for buttonpress
20718
20719
9/10
✓ Branch 0 taken 14620717 times.
✓ Branch 1 taken 2845 times.
✓ Branch 2 taken 676780 times.
✓ Branch 3 taken 13943937 times.
✓ Branch 4 taken 263442 times.
✓ Branch 5 taken 413338 times.
✓ Branch 6 taken 259417 times.
✓ Branch 7 taken 4025 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259417 times.
14623562 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20720 {
20721
2/2
✓ Branch 0 taken 13943937 times.
✓ Branch 1 taken 417363 times.
14361300 if(!msgstr)
20722 13943937 msgorig=0;
20723
20724 14361300 msg_active = false;
20725 14361300 msg_it.reset();
20726 14361300 return;
20727 }
20728
20729
1/2
✓ Branch 0 taken 262262 times.
✗ Branch 1 not taken.
262262 if (!msg_it)
20730 return;
20731
20732 262262 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20733
20734
2/2
✓ Branch 0 taken 258213 times.
✓ Branch 1 taken 4049 times.
262262 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20735 {
20736 4049 msg_it->next();
20737 4049 msg_consume_spaces();
20738 4049 }
20739
20740 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20741 // as possible. This skips the character-by-character animation that usually renders a string
20742 // slowly over many frames.
20743
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 260881 times.
✓ Branch 2 taken 1787 times.
✓ Branch 3 taken 259094 times.
262262 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20744 {
20745
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
81121 while (!msg_it->done())
20746 {
20747
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20748 10 goto breakout; // break out if message speed was changed to non-zero
20749
20750 78489 auto tick = msg_tick(msg_it->character != " ", true);
20751
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20752 534 break;
20753
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20754 2 return;
20755 }
20756
20757
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20758 {
20759 1274 msgclk = 72;
20760 1274 }
20761 1808 }
20762 else
20763 259094 {
20764 breakout:
20765 259104 word tempspeed = msgspeed;
20766
2/2
✓ Branch 0 taken 258141 times.
✓ Branch 1 taken 963 times.
259104 if (do_run_menu)
20767 963 tempspeed = 0;
20768
6/6
✓ Branch 0 taken 207843 times.
✓ Branch 1 taken 51261 times.
✓ Branch 2 taken 121553 times.
✓ Branch 3 taken 86290 times.
✓ Branch 4 taken 111476 times.
✓ Branch 5 taken 10077 times.
259104 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20769 96367 return;
20770 }
20771
20772 // Process the next msg tick.
20773 // This will either print a single character, or process a single string command (with one
20774 // exception).
20775
3/4
✓ Branch 0 taken 163271 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163271 times.
164545 if (!msg_it->done() && !bottom_margin_clip())
20776 {
20777 // This may run an additional tick in the case of a string menu finishing: the first
20778 // tick wraps up the menu, and then a second tick processes the next character or command.
20779 163271 auto tick = msg_tick(true, false);
20780
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161774 times.
163271 if (tick == msg_tick_break)
20781 {
20782 1497 msg_tick_end();
20783 1497 return;
20784 }
20785
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 1 times.
161774 if (tick == msg_tick_exit)
20786 1 return;
20787
20788 // If the next two characters are spaces, consume all upcoming spaces now.
20789
13/20
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 159021 times.
✓ Branch 2 taken 159021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26249 times.
✓ Branch 5 taken 132772 times.
✓ Branch 6 taken 26249 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26249 times.
✓ Branch 10 taken 135524 times.
✓ Branch 11 taken 26249 times.
✓ Branch 12 taken 2752 times.
✓ Branch 13 taken 159021 times.
✓ Branch 14 taken 159594 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
188022 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20790 2179 msg_consume_spaces();
20791 161773 }
20792
20793 163047 msg_tick_end();
20794 14623227 }
20795
20796 124732 int32_t message_more_y()
20797 {
20798 //Is the flag ticked, do we really want a message more y larger than 160?
20799
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124704 times.
✓ Branch 2 taken 124732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124704 times.
✓ Branch 5 taken 28 times.
124732 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20800 124732 msgy+=playing_field_offset;
20801 124732 return msgy;
20802 }
20803
20804 /*** Collision detection & handling ***/
20805
20806 14311729 void clear_script_one_frame_conditions()
20807 {
20808
2/2
✓ Branch 0 taken 38991403 times.
✓ Branch 1 taken 14311729 times.
53303132 for(int32_t j=0; j<guys.Count(); j++)
20809 {
20810 38991403 enemy *e = (enemy*)guys.spr(j);
20811
2/2
✓ Branch 0 taken 662853851 times.
✓ Branch 1 taken 38991403 times.
701845254 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20812 38991403 }
20813 14311729 }
20814
20815 4893978 void check_enemy_lweapon_collision(weapon *w)
20816 {
20817
8/8
✓ Branch 0 taken 4277170 times.
✓ Branch 1 taken 616808 times.
✓ Branch 2 taken 3281369 times.
✓ Branch 3 taken 995801 times.
✓ Branch 4 taken 3219227 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3202489 times.
4893978 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20818 {
20819
2/2
✓ Branch 0 taken 3186674 times.
✓ Branch 1 taken 11214738 times.
14401412 for(int32_t j=0; j<guys.Count(); j++)
20820 {
20821 11214738 enemy *e = (enemy*)guys.spr(j);
20822
20823 11214738 bool didhit = e->hit(w);
20824 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20825 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20826
2/2
✓ Branch 0 taken 10993873 times.
✓ Branch 1 taken 220865 times.
11214738 if(didhit)
20827 {
20828 // !(e->stunclk)
20829 220865 int32_t h = e->takehit(w);
20830
2/2
✓ Branch 0 taken 186989 times.
✓ Branch 1 taken 33876 times.
220865 if (h < 0) // hitby code
20831 {
20832 33876 int indx = Lwpns.find(w);
20833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33876 times.
33876 if(indx > -1)
20834 33876 e->hitby[HIT_BY_LWEAPON] = indx+1;
20835 33876 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20836 33876 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20837
2/2
✓ Branch 0 taken 31471 times.
✓ Branch 1 taken 2405 times.
33876 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
20838 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20839 33876 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20840 33876 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20841 //we may need to handle this in special cases. -Z
20842 // arrow item pierce flag, for example -Em
20843 33876 }
20844
20845
2/2
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 186989 times.
220865 if(h < 0) // hit, check if weapon is "out of pierces"
20846 33876 w->hit_pierce(e, h);
20847
2/2
✓ Branch 0 taken 176579 times.
✓ Branch 1 taken 10410 times.
186989 else if(h > 0) // blocked
20848 10410 w->onhit(false, e, h);
20849
2/2
✓ Branch 0 taken 218191 times.
✓ Branch 1 taken 2674 times.
220865 if(abs(h) == 2)
20850 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20851 218191 }
20852
20853
2/2
✓ Branch 0 taken 11198923 times.
✓ Branch 1 taken 13141 times.
11212064 if(w->Dead())
20854 {
20855 13141 break;
20856 }
20857 11198923 }
20858
20859 // Item flags added in 2.55:
20860 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20861 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20862 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20863 // -Em
20864
6/6
✓ Branch 0 taken 2747946 times.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 2703260 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 54651 times.
✓ Branch 5 taken 2648609 times.
3202489 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20865 {
20866 553880 int32_t itype, pitem = w->parentitem;
20867
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 54651 times.
✓ Branch 3 taken 44686 times.
553880 switch(w->id)
20868 {
20869 454543 case wBrang: itype = itype_brang; break;
20870 54651 case wArrow: itype = itype_arrow; break;
20871 case wHookshot:
20872 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20873 44686 break;
20874 }
20875
2/2
✓ Branch 0 taken 538953 times.
✓ Branch 1 taken 14927 times.
553880 if(pitem < 0) pitem = current_item_id(itype);
20876
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 509194 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
553880 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20877 { //Swap with item
20878 for(int32_t j=0; j<items.Count(); j++)
20879 {
20880 if(items.spr(j)->hit(w))
20881 {
20882 item *theItem = ((item*)items.spr(j));
20883 bool priced = theItem->PriceIndex >-1;
20884 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20885 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20886 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20887 {
20888 if(!Hero.switchhookclk)
20889 {
20890 hooked_comborpos = rpos_t::None;
20891 hooked_layerbits = 0;
20892 switching_object = theItem;
20893 theItem->switch_hooked = true;
20894 w->misc = 2;
20895 w->step = 0;
20896 theItem->clk2 = game->get_item_timeout_dur() / 2;
20897 Hero.doSwitchHook(game->get_switchhookstyle());
20898 if(QMisc.miscsfx[sfxSWITCHED])
20899 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
20900 }
20901 }
20902 }
20903 }
20904 }
20905
6/6
✓ Branch 0 taken 54651 times.
✓ Branch 1 taken 499229 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 320288 times.
✓ Branch 4 taken 499229 times.
✓ Branch 5 taken 320288 times.
553880 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20906 {
20907
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20908 {
20909
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20910 {
20911 4898 item *theItem = ((item*)items.spr(j));
20912 4898 bool priced = theItem->PriceIndex >-1;
20913
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20914
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20915
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20916 {
20917
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20918 {
20919 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20920 }
20921
20922 1724 Hero.checkitems(j);
20923 1724 }
20924 4898 }
20925 88886 }
20926 374939 }
20927
2/2
✓ Branch 0 taken 25560 times.
✓ Branch 1 taken 153381 times.
819517 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20928 {
20929
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153381 times.
190281 for(int32_t j=0; j<items.Count(); j++)
20930 {
20931
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
20932 {
20933 8688 item *theItem = ((item*)items.spr(j));
20934 8688 bool priced = theItem->PriceIndex >-1;
20935
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20936
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20937
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20938 {
20939 7273 int32_t pickup = theItem->pickup;
20940 7273 int32_t id2 = theItem->id;
20941 7273 int32_t pstr = theItem->pstring;
20942 7273 int32_t pstr_flags = theItem->pickup_string_flags;
20943
20944 7273 std::vector<int32_t> &ev = FFCore.eventData;
20945 7273 ev.clear();
20946 7273 ev.push_back(id2*10000);
20947 7273 ev.push_back(pickup*10000);
20948 7273 ev.push_back(pstr*10000);
20949 7273 ev.push_back(pstr_flags*10000);
20950 7273 ev.push_back(0);
20951 7273 ev.push_back(theItem->getUID());
20952 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20953 7273 ev.push_back(w->getUID());
20954
20955 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20956 7273 bool nullify = ev[4] != 0;
20957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
20958
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
20959 {
20960 6197 w->onhit(false);
20961 6197 }
20962
20963
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
20964 {
20965 498 w->dead=1;
20966 498 theItem->clk2 = game->get_item_timeout_dur() / 2;
20967 498 w->dragging=j;
20968 498 theItem->is_dragged = true;
20969 498 }
20970 7273 }
20971 8688 }
20972 36900 }
20973 153381 }
20974 553880 }
20975 3202489 }
20976 4893978 }
20977 14309545 void check_collisions()
20978 {
20979
2/2
✓ Branch 0 taken 4893943 times.
✓ Branch 1 taken 14309545 times.
19203488 for(uint q = 0; q < Lwpns.Count(); ++q)
20980 4893943 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20981 14309545 }
20982
20983 14311729 void dragging_item()
20984 {
20985
2/2
✓ Branch 0 taken 5010644 times.
✓ Branch 1 taken 14311729 times.
19322373 for(int32_t i=0; i<Lwpns.Count(); i++)
20986 {
20987 5010644 weapon *w = (weapon*)Lwpns.spr(i);
20988
20989
4/4
✓ Branch 0 taken 4547506 times.
✓ Branch 1 taken 463138 times.
✓ Branch 2 taken 4855282 times.
✓ Branch 3 taken 155362 times.
5010644 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20990 {
20991
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155362 if(w->dragging>=0 && w->dragging<items.Count())
20992 {
20993 7247 item* dragItem = (item*)items.spr(w->dragging);
20994 7247 dragItem->x=w->x;
20995 7247 dragItem->y=w->y;
20996
20997 // Drag the Fairy enemy as well as the Fairy item
20998 7247 int32_t id = dragItem->id;
20999
21000
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
21001 {
21002 404 movefairynew2(w->x,w->y,*dragItem);
21003 404 }
21004 7247 }
21005 155362 }
21006 5010644 }
21007 14311729 }
21008
21009 57 int32_t more_carried_items(int screen)
21010 {
21011 57 int32_t hasmorecarries = 0;
21012
21013
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21014 {
21015 64 auto spr = (item*)items.spr(i);
21016
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21017 {
21018 57 hasmorecarries++;
21019 57 }
21020 64 }
21021
21022 57 return hasmorecarries;
21023 }
21024
21025 36535 static int count_guys_from_screen(int screen)
21026 {
21027 36535 int count = 0;
21028
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21029 {
21030
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21031 201333 count += 1;
21032 237871 }
21033 36535 return count;
21034 }
21035
21036 // messy code to do the enemy-carrying-the-item thing
21037 14699657 static void roaming_item(mapscr* scr)
21038 {
21039 14699657 int screen = scr->screen;
21040 14699657 auto& state = get_screen_state(screen);
21041
4/4
✓ Branch 0 taken 14663184 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14663122 times.
✓ Branch 3 taken 36535 times.
14699657 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21042 14663122 return;
21043
21044 // All enemies already dead upon entering a room?
21045
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21046 {
21047 return;
21048 }
21049
21050 36535 int guycarryingitem = -1;
21051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21052 {
21053 84544 enemy* e = (enemy*)guys.spr(j);
21054
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21055 {
21056 36535 guycarryingitem=j;
21057 36535 break;
21058 }
21059 48009 }
21060
21061
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21062 {
21063
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21064 {
21065 return; //eSHOOTFBALL are alive but enemies from the list
21066 } //are not. Defer to HeroClass::checkspecial().
21067
21068 77 int32_t Item=scr->item;
21069
21070 77 state.item_state = ScreenItemState::None;
21071
21072
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21073 {
21074 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21075 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21076
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21077 );
21078 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21079 77 state.item_state = ScreenItemState::CarriedByEnemy;
21080 77 }
21081 else
21082 {
21083 return;
21084 }
21085 77 }
21086
21087
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21088 {
21089
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21090 {
21091
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21092 {
21093 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21094 22240 items.spr(i)->y = -128;
21095 22240 }
21096
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21097 {
21098
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21099 {
21100 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21101 {
21102 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21103 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21104 }
21105 else
21106 {
21107 if(guys.spr(guycarryingitem)->extend >= 3)
21108 {
21109 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21110 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21111 }
21112 else
21113 {
21114 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21115 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21116 }
21117 }
21118 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21119 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21120 }
21121 else
21122 {
21123 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21124 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21125 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21126 }
21127 14295 }
21128 36535 }
21129 46044 }
21130 14699657 }
21131
21132 14311729 void roaming_item()
21133 {
21134 29011386 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21135 14699657 roaming_item(scr);
21136 14699657 });
21137 14311729 }
21138
21139 bool enemy::IsBigAnim()
21140 {
21141 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21142 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21143 || anim == a4FRM8DIRB);
21144 }
21145 2418852 int32_t enemy::getFlashingCSet()
21146 {
21147 //Special cset for the dying sprite
21148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if(dying)
21149 {
21150 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21151 return wpnsbuf[spr_death].csets & 15;
21152 else
21153 return (((clk2 + 5) >> 1) & 3) + 6;
21154 }
21155
21156 //Normal cset
21157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if (hclk <= 0)
21158 {
21159 //Special cset for the flashing animation
21160 if (flags & guy_flashing)
21161 return (frame & 3) + 6;
21162 return cs;
21163 }
21164
21165 //Hurt animations
21166
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2414964 times.
2418852 if(type==eeGANON)
21167 3888 return (((hclk-1)>>1)&3)+6;
21168
4/4
✓ Branch 0 taken 2245020 times.
✓ Branch 1 taken 169944 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1757882 times.
2414964 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21169 1757882 return (((hclk-1)>>1)&3)+6;
21170
21171 657082 return cs;
21172 2418852 }
21173
21174 81975581 bool enemy::is_hitflickerframe(bool olddrawing)
21175 {
21176
6/6
✓ Branch 0 taken 81947077 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3972522 times.
✓ Branch 3 taken 77974555 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 772691 times.
81975581 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21177 81202890 return false;
21178
21179
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21180 return false;
21181
21182 772691 int32_t fr = game->get_spriteflickerspeed();
21183
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21184 return true;
21185 772691 return frame % (fr * 2) < fr;
21186 81975581 }
21187
21188 const char *old_guy_string[OLDMAXGUYS] =
21189 {
21190 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21191 // 020
21192 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21193 // 025
21194 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21195 // 030
21196 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21197 // 035
21198 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21199 // 040
21200 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21201 // 045
21202 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21203 // 050
21204 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21205 // 055
21206 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21207 // 060
21208 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21209 // 065
21210 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21211 // 070
21212 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21213 // 075
21214 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21215 // 080
21216 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21217 // 085
21218 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21219 // 090
21220 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21221 // 095
21222 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21223 // 100
21224 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21225 // 105
21226 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21227 // 110
21228 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21229 // 115
21230 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21231 // 120
21232 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21233 // 125
21234 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21235 // 130
21236 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21237 // 135
21238 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21239 // 140
21240 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21241 // 145
21242 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21243 // 150
21244 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21245 // 155
21246 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21247 // 160
21248 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21249 // 165
21250 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21251 // 170
21252 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21253 // 175
21254 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21255 };
21256
21257 15687886 int32_t enemy::get_dmisc(byte index)
21258 {
21259
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21260 {
21261 14611 case 0: return dmisc1;
21262 15885 case 1: return dmisc2;
21263 3236 case 2: return dmisc3;
21264 7390 case 3: return dmisc4;
21265 2144 case 4: return dmisc5;
21266 1794 case 5: return dmisc6;
21267 1051 case 6: return dmisc7;
21268 250 case 7: return dmisc8;
21269 1852 case 8: return dmisc9;
21270 1822 case 9: return dmisc10;
21271 7793452 case 10: return dmisc11;
21272 7597384 case 11: return dmisc12;
21273 case 12: return dmisc13;
21274 308 case 13: return dmisc14;
21275 case 14: return dmisc15;
21276 40 case 15: return dmisc16;
21277 case 16: return dmisc17;
21278 216 case 17: return dmisc18;
21279 case 18: return dmisc19;
21280 case 19: return dmisc20;
21281 case 20: return dmisc21;
21282 case 21: return dmisc22;
21283 case 22: return dmisc23;
21284 case 23: return dmisc24;
21285 884 case 24: return dmisc25;
21286 1120 case 25: return dmisc26;
21287 331 case 26: return dmisc27;
21288 238061 case 27: return dmisc28;
21289 case 28: return dmisc29;
21290 case 29: return dmisc30;
21291 case 30: return dmisc31;
21292 6055 case 31: return dmisc32;
21293 }
21294
21295 return 0;
21296 15687886 }
21297
21298 312 void enemy::set_dmisc(byte index, int32_t value)
21299 {
21300
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21301 {
21302 case 0: dmisc1 = value; break;
21303 case 1: dmisc2 = value; break;
21304 case 2: dmisc3 = value; break;
21305 case 3: dmisc4 = value; break;
21306 case 4: dmisc5 = value; break;
21307 case 5: dmisc6 = value; break;
21308 case 6: dmisc7 = value; break;
21309 case 7: dmisc8 = value; break;
21310 case 8: dmisc9 = value; break;
21311 case 9: dmisc10 = value; break;
21312 case 10: dmisc11 = value; break;
21313 case 11: dmisc12 = value; break;
21314 case 12: dmisc13 = value; break;
21315 case 13: dmisc14 = value; break;
21316 case 14: dmisc15 = value; break;
21317 case 15: dmisc16 = value; break;
21318 case 16: dmisc17 = value; break;
21319 case 17: dmisc18 = value; break;
21320 case 18: dmisc19 = value; break;
21321 case 19: dmisc20 = value; break;
21322 case 20: dmisc21 = value; break;
21323 case 21: dmisc22 = value; break;
21324 case 22: dmisc23 = value; break;
21325 case 23: dmisc24 = value; break;
21326 case 24: dmisc25 = value; break;
21327 case 25: dmisc26 = value; break;
21328 4 case 26: dmisc27 = value; break;
21329 24 case 27: dmisc28 = value; break;
21330 case 28: dmisc28 = value; break;
21331 case 29: dmisc30 = value; break;
21332 case 30: dmisc31 = value; break;
21333 284 case 31: dmisc32 = value; break;
21334 }
21335 312 }
21336